Hello together,
in "Edit" > "Transform Paragraphs" there is a command "Sort Ascending (A-Z)". This command sorts for example the letters h and ḥ as if they were the same character. But they are not the same character: h has the Unicode value U+0068 and ḥ U+1E25. So ḥ should be far behind h and also far behind z (U+007A). Does there exist a macro, that sorts paragraphs and words according to the Unicode value?
Thanks for help!
Ulrich
Unicode sort
Re: Unicode sort
Using a macro you can sort any way you like, as Nisus macro language has a .sortWithCommand command for arrays.
A simple Unicode sort, however, can be achieved with the regular array .sort command using an "s" option.
So a macro that will sort all paragraphs of a document in Unicode order looks like this:
Note that this assumes that there are no empty paragraphs. So this macro should work for files such as word lists.
If you want something that only sorts the current selection, it would need to be modified a bit.
A simple Unicode sort, however, can be achieved with the regular array .sort command using an "s" option.
So a macro that will sort all paragraphs of a document in Unicode order looks like this:
Code: Select all
$doc = Document.active
$paras = $doc.text.find('^.+\n', 'Ea').arrayByMakingValuesDoCommand "subtext"
$paras.sort 's'
$doc.text.replaceInRange Range.new(0,$doc.text.length), $paras.join('')
If you want something that only sorts the current selection, it would need to be modified a bit.
philip
Re: Unicode sort
Dear Philip,
that does exactly what I want and need. I have indeed a word list to sort.
Thank you very much!!
Ulrich
that does exactly what I want and need. I have indeed a word list to sort.
Thank you very much!!
Ulrich