题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
line = input().strip()
ch_list = []
symbol_index = []
for index, ch in enumerate(line):
if ch.isalpha():
ch_list.append((ch,ord(ch.lower())*len(line) + index))
else:
symbol_index.append((ch, index))
ch_list = sorted(ch_list, key = lambda x:x[1])
result = []
for ch, index in ch_list:
result.append(ch)
for ch, index in symbol_index:
result.insert(index, ch)
print(''.join(result))