Sorting vectors according to criteria

Hi guys, i need help in sorting vectors according to criteria.
This was a boolean comparator function that i wrote to sort array values in descending order. However, my assignment needs me to sort them in a more specific criteria like according to area, x and y coordinates , length etc.
However, the boolean function i wrote only takes in the first address of the array and compares it. How do i do it in a way that it compares the values that i desire.

below is the boolean function

1
2
3
4
5
6
7
8
9
10
struct my_function 
{
    bool operator() ( const string& a, const string& b ) const
   {
        float convertA = 0, convertB = 0 ;
        std::stringstream(a) >> convertA ;
        std::stringstream(b) >> convertB ;
        return convertA  > convertB ;
   }
};


The values that i wish to sort are stored in vectors in the following format

[9,9] 12.278

if i want to sort it by 12.278 which is the distance. How do i modify my boolean function to sort according to the distance which is the 3rd value instead of the first?

Thanks in advance =)
Topic archived. No new replies allowed.