Jump to content
  • Advertisement
Sign in to follow this  
stenny

reordering a vector from low to high

This topic is 3999 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

Heya :D, Let me wish you all the best wishes for 2008 in advance, and then move onto my problem. I've got a std::vector with randomly ordered ints, and I'd like them to be ordered from low to high. I've found a way myself, but it seems rather timeconsuming and not clean. I was wondering if there were different ways, or if there isn't just a simple function (whether in the vector, or in de std itself) that'd do this for me. The solution I came up with was to go through the vector with a forloop, and check everytime you enter a new element if it's higher than the next. If so, swap 'em. Do this routine as many times as there are elements in your vector, and it should be ordered. Any better ideas, or is this indeed the way to go? -Stijn

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!