I have 2 lists, for example:
a = ['a','b','c','d','e']
b = ['c','a','dog']
I would like to sort the common elements in list b by the order of list a, to get something like this:
['a','c','dog']
I have read similar questions using sorted(), however I cannot make it work when the lists do not contain the same elements (i.e. 'dog' in list b).
ausingband then sort it?aplays when it’s just sorted naturally like that.['c', 'eagle', 'a','dog']?