Make sort-test.py Python 3 compatible
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 4 Jan 2019 10:23:24 +0000 (11:23 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 4 Jan 2019 10:23:24 +0000 (11:23 +0100)
Python 2 is still supported.

src/test/locale/sort-test.py

index 1dafcedde50769637ef16e38b7a390289ee8fe7e..53019038ab1323a6843f92a0017b49e61231f56e 100755 (executable)
@@ -3,7 +3,7 @@
 import sys, string, locale
 locale.setlocale(locale.LC_ALL, "")
 
-if len(sys.argv) <> 2:
+if len(sys.argv) != 2:
    sys.stderr.write("Usage: sort.py filename\n")
    sys.exit(1)
 
@@ -14,5 +14,5 @@ infile.close()
 for i in range(0, len(list)):
    list[i] = list[i][:-1] # chop!
 
-list.sort(locale.strcoll)
-print string.join(list, '\n')
+list.sort(key=locale.strxfrm)
+print('\n'.join(list))