getting a sorted copy of a list is using the sorted function : Sorted « Buildin Function « Python Tutorial






x = [4, 6, 2, 1, 7, 9]
y = sorted(x)
print x
print y

print sorted([3, 2, 4, 1, 5, 0])             # More iteration contexts








13.43.Sorted
13.43.1.getting a sorted copy of a list is using the sorted function