[Qt-interest] Simple qSort() question

Joshua Grauman jnfo-c at grauman.com
Thu Jan 13 01:03:23 CET 2011


Hello all,

I have three QStringLists that I would like to sort. They all are 
guarenteed to have the same number of items in them with rows that 
correspond to each other. I often want to sort my data based on one of the 
lists. It's easy enough to sort a single list, but then the data in the 
other two lists doesn't match. Is there an easy way to do this that I'm 
not thinking of?

   QStringList list1, list2, list3;

   //populate lists here...

   qSort(list1.begin(), list1.end(), compareFunc);

   //but now list2 and list3's indices don't match list1's

Thanks!

Josh



More information about the Qt-interest-old mailing list