Browse Source

Merge pull request #444 from lurch/test-sorted

Add tests for sorted() function
pull/447/head
Damien George 11 years ago
parent
commit
34ba06b076
  1. 15
      tests/basics/list_sort.py

15
tests/basics/list_sort.py

@ -1,13 +1,28 @@
l = [1, 3, 2, 5] l = [1, 3, 2, 5]
print(l) print(l)
print(sorted(l))
l.sort() l.sort()
print(l) print(l)
print(l == sorted(l))
print(sorted(l, key=lambda x: -x))
l.sort(key=lambda x: -x) l.sort(key=lambda x: -x)
print(l) 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) l.sort(key=lambda x: -x, reverse=True)
print(l) print(l)
print(l == sorted(l, key=lambda x: -x, reverse=True))
print(sorted(l, reverse=True))
l.sort(reverse=True) l.sort(reverse=True)
print(l) print(l)
print(l == sorted(l, reverse=True))
print(sorted(l, reverse=False))
l.sort(reverse=False) l.sort(reverse=False)
print(l) print(l)
print(l == sorted(l, reverse=False))

Loading…
Cancel
Save