Skip to content

Instantly share code, notes, and snippets.

@JohannMG
Created September 23, 2020 02:21
Show Gist options
  • Save JohannMG/76963a995c1113790867bc9b8ca1049a to your computer and use it in GitHub Desktop.
Save JohannMG/76963a995c1113790867bc9b8ca1049a to your computer and use it in GitHub Desktop.
Test if QMap sorts strings by alphabetical order ( Yes it Does
#include <QCoreApplication>
#include <QDebug>
#include <QMap>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QMap<QString, int> map;
map["first_input"] = 1000;
map["second_input"] = 2000;
map["third_input"] = 3000;
map["fourth_input"] = 500;
QMapIterator<QString, int> iter(map);
while(iter.hasNext()){
iter.next();
qDebug() << iter.key() << " = " << iter.value();
}
/* Output: sorts by Key String
"first_input" = 1000
"fourth_input" = 500
"second_input" = 2000
"third_input" = 3000
*/
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment