Sorting a list of lists based on their length