Re: Sorting a map by value
From: tom_usenet (tom_usenet_at_hotmail.com)
Date: 08/24/04
- Next message: Daniel T.: "Re: Sorting a map by value"
- Previous message: tom_usenet: "Re: memset vs fill and iterators vs pointers"
- In reply to: Kevin W.: "Sorting a map by value"
- Next in thread: Joaquín Mª López Muñoz: "Re: Sorting a map by value"
- Reply: Joaquín Mª López Muñoz: "Re: Sorting a map by value"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 24 Aug 2004 12:58:14 +0100
On Tue, 24 Aug 2004 07:55:19 GMT, "Kevin W." <contact@in.sig> wrote:
>How do I sort a map by the value, rather than the key? (either
>automatically or with the sort function.)
You can't - std::map has an invariant that it is sorted by key. You'll
have to copy into a vector or similar first, or perhaps maintain two
parallel maps (key->value and value->key).
Tom
- Next message: Daniel T.: "Re: Sorting a map by value"
- Previous message: tom_usenet: "Re: memset vs fill and iterators vs pointers"
- In reply to: Kevin W.: "Sorting a map by value"
- Next in thread: Joaquín Mª López Muñoz: "Re: Sorting a map by value"
- Reply: Joaquín Mª López Muñoz: "Re: Sorting a map by value"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|