I have a qlist of floats that I would like to sort. However I am looking for a list of the sorted indices.
I could have a qhash of index and float pairs, but I don't know how to sort a qhash on the value.
I have a qlist of floats that I would like to sort. However I am looking for a list of the sorted indices.
I could have a qhash of index and float pairs, but I don't know how to sort a qhash on the value.
Running:
RHEL 5.4
Python 2.7.2
Qt 4.7.4
SIP 4.7.8
PyQt 4.7
So you don't want to sort the original list but rather have a new list that containes a list of indexes of the original list that would make it a sorted list, yes?
I think the easiest way is to use a functor that takes the original list as a parameter as a custom LessThan operator for qSort() that would operate on a list containing indexes of the original list (so starting with a sorted list of 0..(originalList.count()-1)).
I was hoping there was an easier way than that like how you can sort columns on a table.
Are there any examples of howto create a custom LessThan to pass to qSort?
Running:
RHEL 5.4
Python 2.7.2
Qt 4.7.4
SIP 4.7.8
PyQt 4.7
It is quite easy.
And how do you do that?like how you can sort columns on a table.
I'm sure there are some in the docs. And here is one that uses a functor:Are there any examples of howto create a custom LessThan to pass to qSort?
http://qt-project.org/forums/viewthread/4978 (which of course does something completely different from what you want).
Bookmarks