vendredi 28 juin 2019

Sort vector consisting of nested pairs based on different values of pairs with respect to each other?

So I have a vector say:

vector<pair<pair<int,int>,pair<int,int>>>

having elements as:

[(11,13),(2,1)], [(5,6),(1,2)] ,[(9,10),(1,3)] ,[(5,8),(3,4)] , 
[(12,14),(2,7)].

After sorting (i.e. primarily with respect to the first value of the second pair and secondarily with respect to second value of the first pair... So after sorting the output should look like this:

[(5,6),(1,2)] ,[(9,10),(1,3)] ,[(11,13),(2,1)] ,[(12,14),(2,7)] ,
[(5,6),(3,4)]

I had read that we can sort using first or the second value if a vector contains a pair , but how to proceed if a vector contains nested pairs....

Aucun commentaire:

Enregistrer un commentaire