Example:
From this list:
list = [[10, 9, 1], [2, 1, 1,], [4, 11, 16]]
I’d like to have:
print list
[[1, 1, 1], [2, 4, 9], [10, 11, 16]]
Is it possible with the list.sort() function or do I have to write a custom loop ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s an example of flattening, sorting, then rebuilding the nested lists, as @Inerdia suggested in the comments above.
I’ve tried to use generators and iterators where possible, but I’m sure there are cleverer, more efficient ways of getting the result!