Sort std::vector by an element inside?
- by user146780
I currently have a std::vector which holds std::vector of double. I'd want to sort it by the second element of the double vectore. ex:
instead of sorting by MyVec[0] or myvec[1] I wat it to sort myVec[0] and myvec[1] based on myvec[0][1] myvec[1][1]. Basically sort by a contained value, not the objects in it.
so if myvec[0][1] is less than myvec[1][1] then myvec[0] and myvec[1] will swap.
Thanks