Python: Sort a list of lists by length and value using lambda
28. Sort Lists by Length & Value Lambda
Write a Python program to sort a given list of lists by length and value using lambda.
Sample Solution:
Python Code :
Sample Output:
Original list: [[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]] Sort the list of lists by length and value: [[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]
For more Practice: Solve these Related Problems:
- Write a Python program to sort a list of lists first by the sum of their elements and then by the maximum element in each sublist using lambda.
- Write a Python program to sort a list of lists based on the average value of their elements using lambda.
- Write a Python program to sort a list of lists by the product of the elements in each sublist using lambda.
- Write a Python program to sort a list of lists by the count of even numbers in each sublist using lambda.
Go to:
Previous: Write a Python program to sort each sublist of strings in a given list of lists using lambda.
Next: Write a Python program to find the maximum value in a given heterogeneous list using lambda.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.