3

When sorting text with Emacs, the result is wrong for accented characters:

Always Emerald Yesterday Zoo À la campagne Âge Écarlate Être 

Here is the result I would like instead:

À la campagne Âge Always Écarlate Emerald Être Yesterday Zoo 

How can I sort these special characters as regular letters, that is, ignoring the accents?

2 Answers 2

2

sort-lines calls compare-buffer-substrings to compare lines, and it isn't locale-aware. If you want to sort lines and you're on a Unix-like platform (basically anything except Windows, or Windows with basic Unix-like tools available), you can use the external sort command through shell-command-on-region (M-|), with a prefix argument to indicate that you want to replace the region by the output of the command:

ESC 1 ESC | LC_COLLATE=fr_FR.utf8 sort RET 

If your ambient locale already sets your preferred collation order, then you can directly type

ESC 1 ESC | sort RET 
3

Depending on your locale, you can try

 (sort '("Always" "Emerald" "Yesterday" "Zoo" "À la campagne" "Âge" "Écarlate" "Être") #'string-collate-lessp) => ("Âge" "À la campagne" "Always" "Écarlate" "Emerald" "Être" "Yesterday" "Zoo") 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.