Sorting¶
Algorithms: std::sort
¶
Now for something simple …
int int_array[] = { 34, 45, 1, 3, 2, 666 };
std::sort(int_array, int_array + 6);
std::vector<int> int_array;
int_array.push_back(42);
int_array.push_back(7);
int_array.push_back(666);
std::sort(int_array.begin(), int_array.end());
Algorithms: std::sort
, custom comparison¶
bool less_reverse(int l, int r)
{
return l > r;
}
int int_array[] = { 34, 45, 1, 3, 2, 666 };
std::sort(int_array, int_array + 6, less_reverse);