Re: Sorting a map by value

From: tom_usenet (tom_usenet_at_hotmail.com)
Date: 08/24/04


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



Relevant Pages

  • Re: Problems of four-velocity
    ... Tom, pardon top post...I studied your reply. ... >> Tom, Minkowski spacetime is NOT flat, ... > sense that the Riemann curvature tensor is identically zero ... "s" is invariant and is therefore ...
    (sci.physics.relativity)
  • Re: GR ?
    ... > | Measurements of elapsed proper time are invariant. ... > observer around the observed and the rotation of the plane of record of ... > | Tom Roberts tjroberts@xxxxxxxxxx ...
    (sci.physics.relativity)
  • Re: GR ?
    ... | Measurements of elapsed proper time are invariant. ... observer around the observed and the rotation of the plane of record of ... | Tom Roberts tjroberts@xxxxxxxxxx ...
    (sci.physics.relativity)