Support natural sorting by title

Currently when sorting notes by title, the results are sorted by string comparison. If we have notes with titles A9, A80, A100, the ordering becomes A100, A80, A9. It seems helpful to support sorting by natural order (A9, A80, A100).

If this feature makes sense, then we can decide whether it should be configurable or the only way when sorting by title.

I created a preliminary PR:, it uses below logic to compare titles a and b:
a.localeCompare(b, navigator.languages[0] || navigator.language, { numeric: true, ignorePunctuation: true })


Hmm, I believe we'll need tests for that.

Theoretically natural sorting is a good idea. Currently égalité is after Z or z. And I believe we used natural sorting for tags or search results. I can't remember.

Either way, let's see what others think.

Personally I think it is a good idea, just from a user point of view it makes sense, less 'techy' people simply won't understand why "B100" would come before "B20" and may not be aware of how to work around it.

I don't know about that. Haven't all those people been dealing with the same sorting of files in folders on their computers for decades? Whether it's a numbered sequence or dates, I think most people who are tech savvy enough to be taking notes digitally instead of pen and paper understand why B100 comes before B20 in any digital ordering, and that they can relabel to B020 for the desired sequence. Similar for dates.

I'm not convinced, I was dealing with somebody in regards to my day job where this exact conversation came up and they had been the local IT administrator at that location for years. Had to explain that they would need to add an extra 0 to the front of all of their numbers. Still have colleagues naming backup files/folders by suffixing them with "_ddmmyyyy" rather than "_yyyymmdd" and wondering why it is difficult to find anything.

1 Like

Just tried this in Evernote, and it does place B20 before B100, so you may be onto something. I wouldn't have even thought to try that as I'm so conditioned to using zeros or using yyyy/mm/dd for dates.

I hope I am not an asshole saying this, but this has nothing to with being a techie. This is simple logic. Usually that understanding is on the level of elementary school. (Although they usually use multilevel objects (and they certainly don't call them that) and not numbers, but it's the same thing. I can give an example, if necessary.) Maybe junior high school in the US.

I really wish I could agree but I'm always let down by people, I think you would be surprised as to how many people don't intuitively understand things like this. I work in an industry where you think this would be common knowledge (plus a million other things) but sadly this is exactly the kind of thing that ends up being reported as a 'bug'.

Thanks for all the input! I added tests as @tessus suggested.

Ok, but diacritics/umlauts/... are still treated separately, which means they still come after zZ.

I'm really not sure how to handle this. Let's see what Laurent makes of this.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.