The “All” listing in the sidebar sorts punctuation before letters. Somebody asked on Mastodon whether there was a character that would result in a tiddler being placed at the end of the list, other than starting the title with “Z”.
To investigate, I wrote a quick snippet of JavaScript that sorts the first 2000 or so Unicode characters. The result looks like this:
Based on that, I don’t think that there are any easy-to-type symbols that will be sorted after the letters, but there are one or two unusual characters that work: for example, ǂǁΔʘ
For those interested, the JavaScript snippet is:
var codes = [];
for(var code=32;code<2000;code++) {
codes.push(String.fromCharCode(code));
}
codes.sort((a, b) => a.localeCompare(b))
for(var pos=codes.length-100;pos>=0;pos = pos-100) {
codes.splice(pos,0,"\n");
}
var s = codes.join("");
console.log(s);
copy(s);
Edit: uups. Sorry the symbol I did mention here is a different one that Jeremy posted – which does not sort at the end of All-tab :/. .. BUT the concept is OK;
Then select Supplemental symbols. .. At pos (1) you can scroll right for fast selection
Ever since some point in the Windows 10 lifecycle, you can also press Win+. (period) to get a popup where you can select all sorts of smileys and symbols – once you know which ones are sorted after Z…
however I created and tested these and they are by definition not what we need for this use case.
We need to extend sorting in tiddlywiki
Whilst we may wish to revert to a sort order by character position, even if it were only ASCII we don’t want that, because as a rule normally a sort will map a-z and A-Z next to each other.
See ASCII Sort order Chart, note there are non-alphanumeric characters we could use before numbers, lower/upper case, after Uppercase, and after lowercase. But we need a sort algorithm that honours these, but also handles the a-z and A-Z part correctly eg;
! before letters and numbers
> before a-z and A-Z
~ after a-z and A-Z
The method used may need to take account of Unicode’s multi-byte nature if we are to sort the unicode as well.
Noting there are also other a-z and A-Z character sets that deserve this extra treatment as well.
I would be confident there are libraries and functions out there that can honour the use of special characters before and after 0-9 and a-z and A-Z character sets, as well as the standard practices.
This may deserve another and seperate sort operator to be defined because it will be insufficient to make use of the existing sortTiddlers function in $:/core/modules/wiki.js
Workaround;
When wanting a list that puts items with a selected character eg; _ at the top or bottom eg: `~’ of a list you can fake it with three lists, whose result looks like one.
has prefix _ sort and present in first list
!has prefix _ or ~ and sort as desired
has prefix ~ sort and present in last list
Additional note:
We can currently “convert a character number to a character” see [charcode Operator](file:///C:/Scratch/tiddlywiki-sort-operators.html#charcode%20Operator) but we can not do the reverse “converts a character to a character number”.
I expect a “primitive function” to do this may be needed for an improved sort and I would request that one also be made available as an operator.
I use a lot of exotic characters. For me, the use of “Win+.” (period) to trigger the selection of Smilies+…, combined with the use of the Maurycy’s AutoComplete plugin is very useful.
space + ! " # $ % & ' ( ) * + , - . / all come before numbers
Of course $ is used for system tiddlers so you can exclude those beginning $:/ with !is[system]
Some may find # and -, asterix * and ( ) useful here above numbers
the numbers appropriately sorted eg 1 then 10, then 100
then : ; < = > ? @ follow numbers, but proceed a-z and A-Z
There are some characters between a-z and A-Z that also end up proceeding a-z and A-Z [ \ ] ^ _ when using the above sort method. ie :sort: string[get[title]]
Then we get the a-Z and A-Z sorted
Then finaly after all alphabetics the following symbols will sort below the alphabetics { | } ~
So a simple guide would be to use as the first character (or in a sortfield)
! to place something at the top
. at the top just above numbers
0-9 Numbers, honors number schemes
_ after numbers before alphabetics
a-z Alphabetics lowercase first then uppercase for each letter
~ for after Alphabetics
Then finaly Unicode values will come after that, not researched in detail by me (yet)
The list widget enumerates the ASCII characters so you can see what they are, I then go on to explain the sort order as a result of using the filter run :sort: string[get[title]] behaves.
The emphasis is on with useful differences
It is not as simple as the ASCII table because we would not want a lowercase a to come after an uppercase Z for example.
The key point here is it not only satisfies the OT but also the need for other punctuation characters that appear before after numbers and alphanumetics in the sort, or the number 10 to come before 1 etc…
Now by choosing the right character as a prefix to a tiddler title, you can ensure where it comes in the order of things.
The main relationship to the ASCII table is you can see the cluster and order of symbols available in each relative position.
@CodaCoder see my screen shot above, the result has modes before Modes.
As I said it is not important the order of a-z and numbers, in the ASCII table when you use the recommended sort method the result is what I have stated.
it becomes aA - zZ and 1-9 before 10-19 as is expected normally.
It is clearly handled internally perhaps by the javascript function that is being used.
Yes the ASCI List does return ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
Note I removed backtick, and would not recommend | [ ] { } as tiddlywiki tells you.
It has “modes” before “Modes uppercase”. But that’s different. It’s similar to how “AB” sorts before “ABC”. If you try “Modes” and “modes”, you’ll see that upper-case sorts first.
As to numbers, that’s a much harder sorting problem. Normal sorting is character-by-character lexicographic. To handle numbers properly, you’d have to chunk the digits together and convert them to numbers. It’s an interesting problem that’s certainly been solved, but I’ve never looked for (or tried to write) a solution.