1# Example usage:
2list_to_sort = [('U', 23), ('R', 42), ('L', 17, 'D')]
3custom_sort_order = ['R', 'D', 'L', 'U']
4sorted(list_to_sort, key=lambda list_to_sort: custom_sort_order.index(list_to_sort[0]))
5# Where 0 is the tuple index to use for sorting by custom order
6--> [('R', 42), ('L', 17, 'D'), ('U', 23)]