void qSort ( RandomAccessIterator begin, RandomAccessIterator end, LessThan lessThan )
This is an overloaded function.
Uses the lessThan function instead of operator<() to compare the items.
For example, here's how to sort the strings in a QStringList in case-insensitive alphabetical order:
bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
{
return s1.toLower() < s2.toLower();
}
int doSomething()
{
QStringList list;
list << "AlPha" << "beTA" << "gamma" << "DELTA";
qSort(list.begin(), list.end(), caseInsensitiveLessThan);
// list: [ "AlPha", "beTA", "DELTA", "gamma" ]
}
这是QSort的说明
任然要自己重载<