Results 1 to 9 of 9

Thread: Sorting a series of QLists into the same order

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    31
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Sorting a series of QLists into the same order

    Hi, i have a series of QLists (1,2,3,4 etc) with float values all in a random order. They are all of the same length. Now i then use:

    Qt Code:
    1. qSort(list1.begin(), list1.end());
    To copy to clipboard, switch view to plain text mode 

    to sort list1 into ascending order. OK but how can i sort all the other lists based on the order of this list? E.g. if list1[0] is moved to list1[10] during sorting i want the same thing to occur with all other lists no matter what their values.

    Thanks for your help

    Matt

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    62
    Thanked 260 Times in 246 Posts

    Default Re: Sorting a series of QLists into the same order

    The simplest solution is to create a struct (class) with 4 float members, create the QList<Your_Class> and sort it depending on what member you need.
    But off course this might not "fit" your problem well, so provide more information on what you are trying to achieve.

  3. The following user says thank you to Zlatomir for this useful post:

    mobucl (23rd February 2011)

Similar Threads

  1. QList of QLists
    By m15ch4 in forum Newbie
    Replies: 12
    Last Post: 16th October 2013, 22:36
  2. Renaming multidimensional QLists
    By mobucl in forum Newbie
    Replies: 3
    Last Post: 17th December 2010, 09:04
  3. drawing series of rotated ellipses
    By qtn00b in forum Newbie
    Replies: 1
    Last Post: 17th December 2009, 01:51
  4. help using QLists as data in QwtPlotCurve
    By esorensen in forum Qwt
    Replies: 1
    Last Post: 11th July 2008, 19:52
  5. QList of Qlists?
    By markcole in forum Qt Programming
    Replies: 6
    Last Post: 8th July 2008, 05:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.