Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kuphryn

Map Container & Sorting :: STL

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

Hi. Is it possible to sort a map *by value* instead of by key? Moreover, is it possible to declare a map that with a custome sorting algorithm that sorts accord to value? If yes, please give a sample of the sorting function. I can create the function object, but I need to know the parameter. Thanks, Kuphryn

Share this post


Link to post
Share on other sites
Advertisement
The way I see it, sorting a map by value is illogical. Maps are sorted implicitly because of the way they''re done, they''re not sorted because it has to be (though we often take advantage of that).

You can provide your own operator as a template argument, but it will only be used to compare the keys.

What are you trying to do exactly?

----------------
Blaster
Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

Share this post


Link to post
Share on other sites
Okay. Thanks.

The algorithm I am working on a probably simple for most programmers. Nonetheless, I want to come up with my own solution instead of posting it and home someone else solve it.

Hey, I always appreciate help from members.

Kuphryn

Share this post


Link to post
Share on other sites

  • 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!