Boost logo

Boost Users :

Subject: Re: [Boost-users] How to sort multi_index_container + composite_key + Sort by Vale. Is it possible?
From: Igor R (boost.lists_at_[hidden])
Date: 2013-05-18 16:48:30


> Is it possible to sort the container by value? In below example by
> "member<Element_Entry,size_t,&Element_Entry::Id>"
> Or also other keys like: Sort by
> "member<Element_Entry,size_t,&Element_Entry::Index>"

Quoting from the documentation: "Composite keys are sorted by
lexicographical order, i.e. sorting is performed by the first key,
then the second key if the first one is equal, etc. This order allows
for partial searches where only the first keys are specified".
http://www.boost.org/doc/libs/1_53_0/libs/multi_index/doc/tutorial/key_extraction.html#composite_keys

If you need to sort by any arbitrary parameter, make an ordered index
based on it.
In your example the second index is sorted by
member<Element_Entry,size_t,&Element_Entry::Id>.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net