Mega Code Archive

 
Categories / Python Tutorial / Buildin Function
 

Getting a sorted copy of a list is using the sorted function

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