Quick sort with custom function : qSort « Qt « C++






Quick sort with custom function

  
#include <QStringList>
#include <QDebug>

bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
{
  return s1.toLower() < s2.toLower();
}

int main()
{
  QStringList list;
  list << "A" << "b" << "g" << "D";
  qSort(list.begin(), list.end(), caseInsensitiveLessThan);
  qDebug() << list; 
  return 0;
}

   
    
  








Related examples in the same category