题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
s = input() l = list(s) words=[] for i in range(len(l)): val=l[i] if 'a'<=val<='z' or 'A'<=val<='Z': words.append(val) l[i]=None def quicksort(arr): if len(arr)<=1: return arr else: jizhun=ord(arr[0])%97%65 left=[] right=[] mid=[] for val in arr: if ord(val)%97%65<jizhun: left.append(val) elif ord(val)%97%65>jizhun: right.append(val) else: mid.append(val) return quicksort(left)+mid+quicksort(right) new_words=quicksort(words) words=new_words i=0 for val in l: if val==None: print(words[i],end="") i+=1 else: print(val,end="")