题解 | #快速排序#
图片整理
https://www.nowcoder.com/practice/2de4127fda5e46858aa85d254af43941
attr = input() attr2lst = [i for i in attr] def qucik_sort(attr): if len(attr) < 2: return attr else: pivot = 0 less = [ attr[i] for i in range(1, len(attr)) if ord(attr[i]) <= ord(attr[pivot]) ] more = [attr[i] for i in range(1, len(attr)) if ord(attr[i]) > ord(attr[pivot])] return qucik_sort(less) + [attr[pivot]] + qucik_sort(more) lst2attr = "" for i in qucik_sort(attr2lst): lst2attr += i print(lst2attr)