Sort std::vector by an element inside?
Posted
by user146780
on Stack Overflow
See other posts from Stack Overflow
or by user146780
Published on 2010-06-07T22:47:06Z
Indexed on
2010/06/07
22:52 UTC
Read the original article
Hit count: 175
c++
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
© Stack Overflow or respective owner