Sorting QList<QMap<QString , qreal > >
-
Hi,
Use "qSort":http://doc.qt.nokia.com/4.7.1/qtalgorithms.html#qSort or "qStableSort":http://doc.qt.nokia.com/4.7.1/qtalgorithms.html#qStableSort from "Qt Generic Algorithms":http://doc.qt.nokia.com/qq/qq15-qalgorithms.html
Best regards,
Leon -
[quote author="leon.anavi" date="1304771691"]Hi,
Use "qSort":http://doc.qt.nokia.com/4.7.1/qtalgorithms.html#qSort or "qStableSort":http://doc.qt.nokia.com/4.7.1/qtalgorithms.html#qStableSort from "Qt Generic Algorithms":http://doc.qt.nokia.com/qq/qq15-qalgorithms.html
Best regards,
Leon[/quote]On which base should he sort?
he has a
@
class MyContainer : QMap<QString , qreal>{};
QList<MyContainer>;
@To use qSort, MyContainer needs a less then operator.
-
He can use the "qSort(...)":http://doc.qt.nokia.com/4.7.1/qtalgorithms.html#qSort-2 overload that takes an less-than function.
But i have a feeling that he wants something different - because i can't imagine what criteria he wants to use to sort a vector of maps - this is why i asked more information.
-
[quote author="Gerolf" date="1304772427"]
On which base should he sort?he has a
@
class MyContainer : QMap<QString , qreal>{};
QList<MyContainer>;
@To use qSort, MyContainer needs a less then operator.
[/quote]
Hi Gerolf,
I have no idea what is the exact goal as the combination of QMap and QList is a bit strange for sorting :)
@
void qSort ( RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan )
@Can't he use custom lessThan method which compares QMap<QString , qreal > in a desired way (whatever it is) and fits his needs?
amiref, please provide more details as suggested by Zlatomir
Thanks,
Leon -
[quote author="leon.anavi" date="1304773869"]
Hi Gerolf,
I have no idea what is the exact goal as the combination of QMap and QList is a bit strange for sorting :)@
void qSort ( RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan )
@Can't he use custom lessThan method which compares QMap<QString , qreal > in a desired way (whatever it is) and fits his needs?
amiref, please provide more details as suggested by Zlatomir
[/quote]Yes, he can, that's right. But I'm looking for the logic on sorting a list of qmaps....