Sublime Forum

Sort_lines doesn't work with special characters

#1

It seems that using the sort feature to sort lines doesn’t sort alphabetically for special characters. A short example I have is the following

FIELD_X
FIELDS

When you try to sort these two lines, they should switch. In the console, the following works:

a = ["FIELD_X", "FIELDS"]
a.sort()
a  # ["FIELDS", "FIELD_X"

It seems to have this same issue with other special characters also. Any idea why?

0 Likes

#2

By default Sublime Text sorts case insensitively. The underscore has a Unicode code point lower than than a lower case S, hence it is sorted before.

To replicate the behavior of Python’s sort, be sure to use the menu entry Edit > Sort Lines (Case Sensitive).

1 Like