Add tests for sorted() function

and check that sorted(list) produces same output as list.sort()
pull/444/head
Andrew Scheller 2014-04-07 04:41:54 +01:00
rodzic 2bfd2dc770
commit a1a9ab2b2c
1 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -1,13 +1,28 @@
l = [1, 3, 2, 5]
print(l)
print(sorted(l))
l.sort()
print(l)
print(l == sorted(l))
print(sorted(l, key=lambda x: -x))
l.sort(key=lambda x: -x)
print(l)
print(l == sorted(l, key=lambda x: -x))
print(sorted(l, key=lambda x: -x, reverse=True))
l.sort(key=lambda x: -x, reverse=True)
print(l)
print(l == sorted(l, key=lambda x: -x, reverse=True))
print(sorted(l, reverse=True))
l.sort(reverse=True)
print(l)
print(l == sorted(l, reverse=True))
print(sorted(l, reverse=False))
l.sort(reverse=False)
print(l)
print(l == sorted(l, reverse=False))