Sorting list-within-list in Python -


i have list within list in format:

[['39.9845450804', '-75.2089337931', 'paved', ' ', 5.974380011873201], ['39.977111208', '-75.1326105278', 'asphalt', '8', 3.4881723880136537], ['39.9767607107', '-75.1328155113', 'asphalt', '20', 1.5123970222417986], ['40.089750884', '-74.9852538861', 'paved', ' ', 4.296923142303416]] 

where indices latitude, longitude, type of pavement, no. of empty spots, , location in km current location

i want sort unsorted list greatest lowest 4-th index, location in km current location. can assume list-within-list will contains same total number of data points of five.

i know use sort() single-dimensional lists, not quite sure how sort lists within lists.

any assistance appreciated.

if my_data list sort 5th element in my_data do:

sorted(my_data, key=lambda data: data[4]) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -