I'm having a set of lists where I need to sort the list in a specific order.
List:
colour_1 = ['orange','purple','yellow','black','brown','pink','blue','green']
colour_2 = ['white','violet','blue','red','yellow','purple']
colour_3 = ['Gray','silver','green','yellow','gold']
The order which i need to sort:
custom_order = ['blue','yellow','green','purple',#remaining_colours]
Expected output:
colour_1 = ['blue','yellow','green','purple','orange','black','brown','pink']
colour_2 = ['blue','yellow','purple','white','violet','red']
colour_3 = ['yellow','green','gray','silver','gold']
What I need:
1)Check if values in custom_order are present in colour_lists.
2)If present in colour_list, arrange them in the specified order. If the values not present skip the value and search for the next value. (If "yellow" is not present in colour_list skip "yellow" and search if "green" is present in colour_list)
3)Once the custom_order is inserted, append the remaining values to the list.
How to sort the list in the custom order in python?
Thanks in advance.