Sorting with bool compare

Hello guys ,

Today i was solving a problem and thought about it really hard and then i couldn’t get to know the answer and i saw a solution for a hint
And i was surprised to know that i was doing the same code but the difference was i was just sorting while he was doing sorting with bool compare
Here is the image of the bool function compare :

41%20PM

And i didnt understand what the fuction is doing
Can someone pls tell me what does this mean ?

Thanks a lot !!

1 Like

If ip is some pair, and S stands for second, ----then this sorts the vector or whatever in ascending order of the second element of pair. Or if its for struct, then according to S parameter of it.

2 Likes

Oh ok
Understood now
Thanks a lot for your time @ks3rr !!

2 Likes

you can even sort a 2-D array. Here is one of the solutions.

1 Like