using sorting in cpp code example Example: sort c++ sort(arr, arr+length); //increase sort(arr, arr+length, greater<int>()); //decrease