A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a Python program to sort a given list of lists by length and value
Q:

Write a Python program to sort a given list of lists by length and value

0

Write a Python program to sort a given list of lists by length and value.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def sort_sublists(input_list):
    input_list.sort()  # sort by sublist contents
    input_list.sort(key=len)
    return input_list

list1 = [[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]]
print("Original list:")
print(list1)
print("\nSort the list of lists by length and value:")
print(sort_sublists(list1))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now