题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
while True: try: s=input() sdic=dict() sli=[] for i,val in enumerate(s): if val.isalpha(): sacsii=ord(val) if sacsii>96: s_sort=sacsii-32 else: s_sort=sacsii sli.append([val,s_sort]) else: sdic[i]=val sli.sort(key=lambda x:x[1]) li=list(map(lambda x:x[0],sli)) for i,val in sdic.items(): li.insert(i,val) print(''.join(li)) except: break