Logo

Programming-Idioms

  • Python
  • Scala

Idiom #297 Sort a list of strings, case-insensitively

Sort the string list data in a case-insensitive manner.

The sorting must not destroy the original casing of the strings.

data.sort(key=str.lower)
data.sort((a, b) => a.toUpperCase().compareTo(b.toUpperCase()));

New implementation...