QSort error
-
Hi,all.i'm want to use qsort to sort QStringList like "50% 60% 70%",and i write a function :
@
bool compareItem(QString &first,QString &second)
{if(-1 == first.contains("%") || (-1 == second.contains("%"))) return false; int num1 = 0,num2 = 0; num1 = first.remove(first.indexOf("%")).toInt(); num2 = second.remove(second.indexOf("%")).toInt(); return first < second;
}
@used it as
@
qSort(beforeSort.begin(),beforeSort.end(),compareItem),
@but can't compiled with error:
@
xxx:603: error: no matching function for call to 'qSort(QList<QString>::iterator, QList<QString>::iterator, <unresolved overloaded function type>)'
/opt/qt-qvfb/include/QtCore/qalgorithms.h:184: note: candidates are: void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = QList<QString>::iterator, LessThan = bool (xxxWidget::*)(QString&, QString&)]
@
can someone help me ? Thanks a lot ![edit: added missing coding tags @ SGaist]
-
Please, using code tag for your code.
qSort is "absolute":http://qt-project.org/doc/qt-5/qtalgorithms-obsolete.html#qSort, try "sort":http://www.cplusplus.com/reference/algorithm/sort/?kw=sort