
Uthpal Urubail <uthpal.urubail <at> altair.com> writes:
I am having below composite container. I am looking to sort the container by member<CA,std::string,&CA::card> at the end. Can some one help me to achieve this?
Hi Uthpal, Please use [multi_index] (or whatever the lib your post is about) in your subject line, as suggested in http://www.boost.org/community/policy.html Thank you! As for your question, to have the elements in your duplicateBook sorted by card, you have sceral options: 1. Add an additional index based on card: ordered_non_unique<member<CA,std::string,&CA::card>> 2. Create a std::vector<CA*>, populate it with pointers to the elements of duplicateBook and std::sort by card. 3. Add a sequenced or random_access index and sort by card. 1 is the simplest. You want to choose 2 rather than 1 if the operation is unfrequent (having an additional index imposes a penalty on memory and overall container performance.) 3 is a sort of compromise between 1 and 2: there's a memory penalty but you only pay for sorting when you need it. Best, Joaquín M López Muñoz Telefónica Digital