Sorting array from draft.query() by "text"

When using draft.query(), the array of drafts can be sorted by “created”, “modified”, “accessed”, but not “text” (alphabetical order). I was wondering if there is a way to do this, since workspaces can be sorted by “created”, “modified”, “accessed”, or “text”.

Could that be the default, if no sort parameter is provided? Just guessing based on other javascript conventions I’ve run across (though I’m by no means good at js).

Yes, my understanding is that it is the default. Perhaps it would be possible to create an array of drafts based on a workspace, which workspace is sorted by text from the Drafts’ default settings.

Try “name” as the sort parameter, I think that will work and the docs are not complete.

You can, of course, also re-sort the result array at any time, something like:

let drafts = Draft.query(...); // use real params
drafts.sort(function(a, b){ return a.content < b.content; });

Works great, thank you!