Sort elements in a list : List Sort « List « Python






Sort elements in a list

Sort elements in a list
 

L = ['spam', 'Spam', 'SPAM!']

print L.append('please')                # append method call
print L

L.sort()                          # sort list items ('S' < 'e')
print L

           
         
  








Related examples in the same category

1.Sorting a list.
2.List sort() DemoList sort() Demo