sorting the list by inner elements

ketulp_baroda at yahoo.com ketulp_baroda at yahoo.com
Wed Mar 24 08:43:45 EST 2004


Hi, all

 I want to sort the list,the form of my list is

  name_city_list=[['jack','new york'],['mac','london'],['alice','paris']]

all inner list has same format i.e first is name and second is city.
now I want to sort it by the second element of the inner list(by city name).

i.e after sorting my list should be like this

  name_city_list=[['mac','london'],['jack','new york'],['alice','paris']]

how can I do this,

any way out ?



More information about the Python-list mailing list