import re def mix_sorted(a_list): a_list = {i: (i if isinstance(i, int) else int(re.match(r'd+', i).group())) for i in a_list} return sorted(a_list, key= lambda x: distribution[x])