Если я правильно понял, что именно вы хотите достичь, это будет сделать это:
list_of_words = ['hoop t','hot op','tho op','ho op t','phot o']
# first sort the words in each string by their length, from longest to shortest
for i, words in enumerate(list_of_words):
list_of_words[i] = sorted(words.split(), key=len, reverse=True)
# second sort the list by how many words there are in each sublist
list_of_words.sort(key=lambda words: len(words)) # sorts list in-place
# third, join the words in each string back together into a single string
for i, words in enumerate(list_of_words):
list_of_words[i] = ' '.join(words)
# show results
print(list_of_words)
['hoop t', 'hot op', 'tho op', 'phot o', 'ho op t']
Так что ваш вопрос? –
Как отсортировать их в python –
Просьба уточнить ваш вопрос, указав, что именно вы спрашиваете, какова ваша проблема и что вы пробовали до сих пор. – Xenon