FileBrowser.cpp : add naturalCompare function
add naturalCompare function :In the current FileBrowser::addItems , the ordering of directories and files is based on alphabetical order. Especially when dealing with directories, the code is sorted by name (fileName < d->text(0)). To implement natural sorting, we need to implement a custom comparison function. For example, you can add "file1", "file2",... ", "file10", rather than alphabetically placing "file10" before "file2". This is a realization idea, personal ideas only provide reference
Take a look at #5772 too.
Thanks for the contribution ;-)
The sorting function looks good, but it only appears to be applied to root directories. Would you be able to apply it to all file browser entries?
Another nitpick, @sakertooth sped up file browser searching recently. Hope this PR doesn't undo his speed benefit accidentally, in favour of aesthetics.
I looked for another method. On quick googling, i found that QString has a compare function. Why not use that instead?
Another method i found. https://stackoverflow.com/questions/11933883/sort-filenames-naturally-with-qt
To achieve natural sorting, we can use QCollator instead. I think what is best is to make a global pure function for natural sorting, so that anyone that needs to do a natural sort can choose to do so.