items = [('A', 1000), ('B', 2000), ('B', 1500), ('A', 1700), ('B', 1000), ('A', 2000)] items.sort(key=lambda x: int(x[0] != 'A') * 1e5 + x[1]) print(items)
To embed this program on your website, copy the following code and paste it into your website's HTML: