for x in input: output[count[key(x)]] = x count[key(x)] += 1 return output colegiohispanomexicano.net – Algorithms Notes 163