Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

std::sort with std::pair in a std::vector

This topic is 2164 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


std::vector<std::pair<int, int*>> temp;
std::pair<int, int*> pair;
//add to pair here
temp.push_back(pair);
std::sort(temp.begin(), temp.end());


I am guessing this code works and will sort the temp vector and not hidden gotchas? I just need the pointers sorted based on some priority value

Thanks

Share this post


Link to post
Share on other sites
Advertisement
It will sort the pairs sorted first by the first element of each pair and then the value of the pointer in case of ties.

Share this post


Link to post
Share on other sites

It will sort the pairs sorted first by the first element of each pair and then the value of the pointer in case of ties.


Thanks for the help SiCrane. Should work for what I need.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!