Search code examples
c++2dquicksortqsort

C++: How-to sort 2-d array with qsort?


Example:     Result:

[9,1]        [0,5]
[5,2]        [2,4]
[6,3]        [5,2]
[2,4]        [6,3]
[0,5]        [9,1]

I know that the meaning lies in the comparison function. How to sort in ascending or descending order.

Thanks.


Solution

  • use std::sort from the <algorithm> header

    you can use a lambda expression as comparison function