Let's say I have such a list:
['word_4_0_w_7', 'word_4_0_w_6', 'word_3_0_w_10', 'word_3_0_w_2'] and I want to sort them according to number that comes after "word" and according to number after "w". It will look like this:
['word_3_0_w_2', 'word_3_0_w_10', 'word_4_0_w_6', 'word_4_0_w_7'] What comes in mind is to create a bunch of list and according to index after "word" stuff them with sorted strings according "w", and then merge them.
Is in Python more clever way to do it?
sorted(words, key=lambda word: (int(word[5]), int(word[11:]))