Sorting and spaces.

Chris Angelico rosuav at gmail.com
Thu May 31 17:35:29 EDT 2018


On Fri, Jun 1, 2018 at 6:51 AM, Paul <tallpaul at gmail.com> wrote:
> In the US, at least, spaces should sort before letters.
>
> MRAB brought up an important point. It depends on your purpose, of course,
> but having all the capitalized-beginning items appear separately from all
> of the lower-cased-beginning items can be very annoying to a user.

And that's why locale-based sorting exists. You can't set a single
definition of sorting and expect it to work for everyone. In fact,
even within a language, there can be different sorting rules for
different types of data (a list of names might be sorted one way, but
a list of book titles differently). Peter's recommendation covers most
of that, modulo the types-of-data complexity; you should be able to
sort German text according to German rules, and Dutch text according
to Dutch rules.

ChrisA



More information about the Python-list mailing list