只要計算字母出現次數就好了(43ms,6.1MB)
a='ABCDEFGHIJKLMNOPQRSTUVWXYZ' b=input() for c in a: print(c*(b.count(c)),end='')