1) When using vector: sort(arr.begin(), arr.end()); 2) When using array: sort(arr, arr+n); sort(arr, arr+n, greater<int>()); //sorts in descending