Operating system
Linux
Joplin version
3.5.13
What issue do you have?
I have noticed that Joplin doesn't sort well. When I create a note, I give it a number at the beginning of the title. This usually results in proper sorting, but I have seen lately that Joplin will list several notes in order then display two or three out of order, then go back to in-order. for example 1,2,3,8,9,4,5,6,7,10. I have tried re-typing the numbers but that doesn't seem to work. Any ideas?
If you use numbers at the beginning of note titles for alphabetical sorting, you should always keep the same number of digits.
For example, instead of:
1, 2, 3, 4, 5, 10
use:
01, 02, 03, 04, 05, 10
or even:
001, 002, 003, 010
The reason is that Joplin sorts titles alphabetically, not numerically. Otherwise, the number 10 may appear before 2 or create other strange ordering behavior.
So I should use a, b, c, etc? I tried adding the zero for single digit entries, but that actually made sorting more "unsorted" and didn't address 37 being listed before 30. Are there other ways to sort? I'm trying to keep these entries in order (mostly) by date, does Joplin sort by date?
Update: I added the zero before the single digit numbers and now those entries have disappeared
found them listed under "conflicts"
Not sure how, but switching between increasing and decreasing order seems to have fixed this (if temporarily).
I believe Joplin sorts numerically @Eduardo
Text Fields (Alphabetical)
When sorting by text fields like title, Joplin uses getCollator() for locale-aware string comparison, which handles international characters and natural sorting (e.g., "A3" comes before "A20"). Note.ts:313-331 Note.test.ts:339-364
const collator = getCollator();
return notes.sort((a: NoteEntity, b: NoteEntity) => {
if (noteOnTop(a) && !noteOnTop(b)) return -1;
if (!noteOnTop(a) && noteOnTop(b)) return +1;
let r = 0;
for (let i = 0; i < orders.length; i++) {
const order = orders[i];
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
let aProp = (a as any)[order.by];
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
let bProp = (b as any)[order.by];
if (typeof aProp === 'string') aProp = aProp.toLowerCase();
if (typeof bProp === 'string') bProp = bProp.toLowerCase();
if (order.by === 'title') {
r = -1 * collator.compare(aProp, bProp);
} else {
if (aProp < bProp) r = +1;
if (aProp > bProp) r = -1;
}
if (order.dir === 'ASC') r = -r;
if (r !== 0) return r;
What if I used a date? for example 20260514?
dates in the format YYYYMMDD follow the natural ordering for numbers, so they will be correctly sorted as well. However, the collator doesn't recognize it as a date as such