Is there a simple way to sort a nested list by any element of the inner list ? We can sort a list with list_name.sort() statement but can we sort by any desired element or even by any desired list elements element ?
books = [
['123', 'book1', 25],
['243', 'book2', 30],
['874', 'book3', 15],
['519', 'book4', 20],
['745', 'book5', 10]
]
- index of inner lists represent prices, I want to sort this list by prices. How can I accomplish this without any fancy loop used ?