Created
September 23, 2020 02:21
-
-
Save JohannMG/76963a995c1113790867bc9b8ca1049a to your computer and use it in GitHub Desktop.
Test if QMap sorts strings by alphabetical order ( Yes it Does
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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