One thing that I’m really missing is the ability to sort cards numerically in Anki. This includes the order of cards shown in the card browser and the order in which they’re presented when learning.
Anki can do numerical sorting only if the field contains only numbers, e.g. 1.
The sorting is done at the database level, which is only able to sort in numeric order if the fields contain nothing but digits. - Damien Elmes
But a field often contains alphanumeric characters when needing to distinguish several “levels”, e.g. L1E1. Currently, Anki orders it alphanumerically, which is usually not what one expect, e.g.
I think what this means is that when the database is queried for results, and asked for a sorted result, it can only provide such a sorting for numerical fields. This depends on the database backend, not really on the Anki code.
One thing that I’m really missing is the ability to sort cards numerically in Anki. This includes the order of cards shown in the card browser and the order in which they’re presented when learning.
Anki can do numerical sorting only if the field contains only numbers, e.g. 1.
The sorting is done at the database level, which is only able to sort in numeric order if the fields contain nothing but digits.
But a field often contains alphanumeric characters when needing to distinguish several “levels”, e.g. L1E1. Currently, Anki orders it alphanumerically, which is usually not what one expect, e.g.
Do you know in advance the highest-order digit needed to accommodate your likely highest alphanumeric value?
For example, if the order is 3, then you can do the following:
L001E001
L001E002
…
L010E001
L010E002
…
L011E001
L011E002
…
…
L002E001
L002E002
…
L020E001
L020E002
…
L021E001
L021E002
…
.
If there are no errors in the above, I shall be most surprised.
I found a workaround. I added a new field in my custom note type, named it ID, and give each new card its specific umber. This way i am able to sort my cards numerically.
I came to the forum to ask something similar. In my case, about half of my decks sort into something like this:
Psalm 103:10-12
Psalm 107:1
Psalm 10:4
Psalm 11:1
Psalm 122:1
Psalm 139:7-10
Psalm 19:1-3
Psalm 1:1-2
The comment posted above about how sorting is done at the database level is helpful for understanding the challenge. As a PHP programmer, I would look to solve this by passing the results from the database (mysql in my case) through natsort() (or similar for arrays). It would be an easy “fix.”
Does such a function exist for the language Anki is written in? If it could be something as straightforward as that, I would love for it to be implemented. However, not knowing the language nor how the code is set up, I would be of the opinion to leave it alone if it is not a simple change.