Consider this list.
input_list = ['Saturday', 'Tuesday', 'Sunday', 'Monday', 'Thursday', 'Wednesday', 'Cheeseburger', 'Friday']
I want to sort it based on partial matches of a 2nd list.
list_sorter = ['Mon', 'Tue', 'Wed']
so that
output_list = ['Monday', 'Tuesday', 'Wednesday', 'Cheeseburger', 'Friday', 'Saturday', 'Sunday','Thursday']
Storing the sorted list to input_list is preferred. Thanks in advance for the assistance.
Edit:
I've tried sorted(input_list, key = list_sorter.index)
Which errors.
ValueError: 'Saturday' is not in list
I've tried sorted(input_list, key = lambda x: x in list_sorter)
Which is also not correct.
Edit 2: It should not be assumed the text is at the start of the word. Sorry for the late edit, it didn't occur to me until I saw the replies.
list_sorter = ['Mon', 'Tue', 'rida']
output_list = ['Monday', 'Tuesday','Friday','Cheeseburger', 'Saturday', 'Sunday','Thursday','Wednesday']
when there's a partial match on list_sorter should also be supported.