C++ examples for STL Algorithm:sort
Sorts an array of integers
#include <iostream> #include <algorithm> using namespace std; // array of numbers int arr[] = {45, 2, 22, -17, 0, -30, 25, 55}; int main()/*from www . j av a 2 s . c o m*/ { sort(arr, arr+8); // sort the numbers for(int j=0; j<8; j++) // display sorted array cout << arr[j] << ' '; cout << endl; return 0; }