Well, it might be possible to use a custom sort function - what's the
context of this (e.g. a FET macro call)?
-- F.
For FET, you could use something like this:
---------------
<<forEachTiddler
sortBy 'stripNonAlphaNumerics(tiddler.title)'
script 'function stripNonAlphaNumerics(str) {
return str.replace(/[^A-Za-z0-9]/g, "");
}'
>>
---------------
(The stripNonAlphaNumerics function simply removes all characters that
are not Latin letters on digits, so those are ignored when sorting.)
However, TagsTreePlugin* doesn't support a custom sort function, so
you'd have to take that up with Pascal...
-- F.
> (The stripNonAlphaNumerics function simply removes all characters that
> are not Latin letters on digits, so those are ignored when sorting.)
... make that "letter or digits"...
Also, you could simplify this:
<<forEachTiddler
sortBy 'tiddler.title.replace(/[^A-Za-z1-9]/g, "")'
>>
> However, TagsTreePlugin* doesn't support a custom sort function
* http://visualtw.ouvaton.org/VisualTW.html#TagsTreePlugin
-- F.
Yeah, it wouldn't - I went only by the title of this thread, but
stripping all non-alphanumeric characters obviously doesn't suffice,
because that doesn't leave anything to sort by.
Now, we could come up with a list of problematic letters and leave the
rest to the standard sorting mechanism - would that work?
You can try it yourself by using this expression:
sortBy 'tiddler.title.replace(/[abcdefg]/g, "")'
Where "abcdefg" is the list of characters to ignore.
The alternative is to write an entirely different sorting algorithm that
properly handles the entire Greek alphabet...
-- F.
Yes; instead of the single generic pattern ...
tiddler.title.replace(/[^A-Za-z0-9]/g, "")
... you can specify one replacement operation for each such character:
tiddler.title.replace(/a/g, "x").
replace(/b/g, "y").
replace(/c/g, "z");
where a, b, c are the original characters, and x, y, z are the letters
to replace them.
So that's gonna be a bit of a lengthy expression, but it works. There
might be an impact on performance, but that remains to be seen.
> 4 punctuation combinations times 7 vowels times 2, one for
> caps and one for lowercase.
If a group of character is to be replaced with the same letter, you can
group those by enclosing them in square brackets:
tiddler.title.replace(/[abc]/g, "x").
replace(/[def]/g, "y").
replace(/[ghi]/g, "z");
This would convert a title "abcdefghi" to "xxxyyyzzz".
HTH.
-- F.