sort sequence of numbers in card browser
When sorting the cards in the card browser by name and the name consists of numbers, it orders them fine by increasing number, but only until 100. 101-109 is then placed after 10, 110-119 after 11, and so on.
How can I sort my cards so that the numbers are increasing steadily just like a human would count them (1,2,3,4,5 ... 100,101,102) and not mixing up eventually?
-
Jorma Spitz commented
a simple work around is to add zeros in front of the numbers. If you expect to have more than 999 cards you should write four digits for each number (0001, 0002, ..., 1004, ...)
The sorting algorithm seems to look at numbers as if it would be normal text.
It sorts like this:
1
10
100
2
20
200
3
30
300The order with leading zeros would be:
001
002
003
010
020
030
100
200
300by the way: isn't it posible to change the sorting behaviour without implementing a custom sort but using just setSortRole() as mentioned here: http://stackoverflow.com/questions/6568161/qt-sorting-is-wrong-when-using-qsortfilterproxymodel-on-number-strings-and-gett ??
Forgive me if not, I don't know Qt for now... and thanks for this great program, I'm using it since years :-) -
The sorting is handled directly by the Qt library for efficiency reasons, so if we were to implement a custom sort in Mnemosyne itself, it would slow things down enormously...