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.

Qt Code:
  1. typedef QHash<QString, int> WordCount;
  2. ....
  3.  
  4. QList<QPair<WordCount,int> > items;
  5. QPair<WordCount,int> pair;
  6. pair.first = myHash;
  7. pair.second = totalKeys;
  8. items.append(pair);
  9.  
  10. qSort(items.begin(), items.end(), sorting); // :confused:
  11.  
  12. bool sorting(const QPair<WordCount,int>& e1, const QPair<WordCount,int>& e2) { // sorting by QHash Value
  13. //if (e1.first.value() < e2.first.value()) return true; // *** Not Working *** :confused:
  14. return true;
  15. }
To copy to clipboard, switch view to plain text mode