PDA

View Full Version : sorting QList<double>



timmu
24th August 2012, 13:04
How to sort QList<double>. Unfortunately sort() is not a member of this class. What would be the best way to do this sort? Is this the best way:



qSort(mylist.begin() , mylist.end());

spirit
24th August 2012, 13:13
It's the only way to sort lists. :)

Zlatomir
24th August 2012, 13:36
QList is not the Qt way for std::list, i mean that it's not a linked list, read more here (http://qt-project.org/doc/qt-4.8/qlist.html#details).

amleto
24th August 2012, 14:31
It's the only way to sort lists. :)

QList has random access. You can therefore use any of these (http://www.cplusplus.com/reference/algorithm/sort/), I believe.

spirit
24th August 2012, 14:38
QList has random access. You can therefore use any of these (http://www.cplusplus.com/reference/algorithm/sort/), I believe.
Then is not going to be Qt-way sorting.

amleto
24th August 2012, 14:59
so?

1234567890

spirit
24th August 2012, 15:19
so?

1234567890
There is nothing "so". You blame people to not start posts which don't have anything w Qt, but here you suggest to use the way which doesn't have anything to Qt. ;)

amleto
24th August 2012, 16:35
I was just saying qSort is not 'the only' way as you suggested.