Trader
7th July 2010, 12:58
Hi guys,
I'm trying to order a QList of QPair <QHash <QString, int>, int> (ordered by the value of QHash).
I do not know if this form is correct, but is not giving error.
I am not able to create the qSort(items.begin(), items.end(), sorting); and their method of ordering (sorting) and do not know if I have to use the operator<
Could anyone help me?
Thank you.
typedef QHash<QString, int> WordCount;
....
QList<QPair<WordCount,int> > items;
QPair<WordCount,int> pair;
pair.first = myHash;
pair.second = totalKeys;
items.append(pair);
qSort(items.begin(), items.end(), sorting); // :confused:
bool sorting(const QPair<WordCount,int>& e1, const QPair<WordCount,int>& e2) { // sorting by QHash Value
//if (e1.first.value() < e2.first.value()) return true; // *** Not Working *** :confused:
return true;
}
I'm trying to order a QList of QPair <QHash <QString, int>, int> (ordered by the value of QHash).
I do not know if this form is correct, but is not giving error.
I am not able to create the qSort(items.begin(), items.end(), sorting); and their method of ordering (sorting) and do not know if I have to use the operator<
Could anyone help me?
Thank you.
typedef QHash<QString, int> WordCount;
....
QList<QPair<WordCount,int> > items;
QPair<WordCount,int> pair;
pair.first = myHash;
pair.second = totalKeys;
items.append(pair);
qSort(items.begin(), items.end(), sorting); // :confused:
bool sorting(const QPair<WordCount,int>& e1, const QPair<WordCount,int>& e2) { // sorting by QHash Value
//if (e1.first.value() < e2.first.value()) return true; // *** Not Working *** :confused:
return true;
}