Array sort?

How can I sort an array in, for example, a-/de-scending order?

I thought of a way, using nested loops and if statements, but it's very inefficient, and there is most probably an easier way.

Thanks.
google "sorting algorithms"

there are gazillions ranging from O(n log n) to O(n^2).

bubble sort, insertion sort, radix sort, merge sort, quick sort, shell sort, etc, etc, etc, etc.

In the example, they provide numerous methods for sorting in ascending order. Sort uses std::less by default.
http://cplusplus.com/reference/algorithm/sort/

Simply change it to use std::greater to sort in the opposite direction. Here is an example on sorting in descending order. Was that the question?
http://cplusplus.com/reference/std/functional/greater/
Topic archived. No new replies allowed.