Sort QFileInfoList to handle file names that end with numbers
-
Currently if you have files that end in numbers, a QFileInfoList list created by calling dir.entryInfoList() appears in the following order,
test_1.txt,
test_10.txt,
test_11.txt, etcI want to sort a QFileInfoList so that it is number aware i.e the list is as follows,
test_1.txt
test_2.txt
.....
test_10.txt
test_11.txtAny help much appreciated.
-
Take Name of file, split with each name with "_",
Take the second for each (1=> test 2=>1.txt)
then split this with "." now you have 1 2 3 4 5 6 7 8 9 10 11 ... -
If people are interested....I did some more searching and thinking and the way to do this is to use a qSort with a custom struct that enables a "Natural Sort",
http://stackoverflow.com/questions/11933883/sort-filenames-naturally-with-qt