A feature request

Related to this issue I noticed that the sorting order in Tools->Note Attachments... is a bit... off when sorting via filename.

I had a look in the resources table and didn't realise that case sensitive sorting is a thing in SQLite (only really used Oracle and MSSQL but entirely possible I've never come across data that has a mixed case starting character) and to me this doesn't make a huge amount of sense when searching in a list such as this.

In terms of SQL this:

SELECT *
FROM resources
ORDER BY title ASC;

Will return A.xyz, B.xyz, C.xyz, a.xyz, b.xyz, c.xyz.

Whereas:

SELECT *
FROM resources
ORDER BY title COLLATE NOCASE ASC;

Will return A.xyz, a.xyz, B.xyz, b.xyz, C.xyz, c.xyz

The latter of the two is what I would normally expect when sorting a column in something like that tool.

Unfortunately I'm not a programmer beyond some VBA macros and some SQL wrangling (although I'm doing a small amount of learning in my own time) but I've had a dig around the code and whilst I've not been able to find exactly how the application is accessing the database (I'm guessing something other that straight up embedding the queries...) I did find the following in joplin/packages/app-desktop/gui/ResourceScreen.tsx - async reloadResources:

order: [{
	by: getSortingOrderColumn(sorting.order),
	dir: sorting.type,

In a completely different file I found something similar but with an extra argument (assuming 'caseInsensitive: true' equates to 'COLLATE NOCASE'):

return [{
	by: orderBy,
	dir: orderDir,
	caseInsensitive: true,

Is anyone able to tell me if

  1. I'm barking up the wrong tree entirely,
  2. if this is a bug and if so does it need to be created or is this as intended and
  3. would adding in the 'CaseInsensitive: true' argument to that function actually do what I hope - or if not could you point me in the right direction - i.e. where the the query is actually being constructed

I'd love to collaborate and help one day in the future but this is about the limit of my ability at the moment.