python解法
字符串排序
http://www.nowcoder.com/questionTerminal/5190a1db6f4f4ddb92fd9c365c944584
这题反复写了很多遍,原来写的 s=raw_input()不行
改成 s = sys.stdin.readline().strip() 读取一行
encoding: utf-8
import sys
if name == 'main':
while 1 :
s = sys.stdin.readline().strip()
if s == '':
break
i = 0
str_new = ''
while i < len(s):
# 如果是字母
if (s[i] >= 'a' and s[i] <= 'z') or \
(s[i] >= 'A' and s[i] <= 'Z'):
str_new = str_new + s[i]
i = i + 1
list = sorted(str_new, key=str.upper)
# print list
i = 0
j = 0
list1 = ''
while i < len(s):
if (s[i] >= 'a' and s[i] <= 'z'):
list1 = list1 + list[j]
j = j + 1
elif s[i] >= 'A' and s[i] <= 'Z':
list1 = list1 + list[j]
j = j + 1
else:
list1 = list1 + s[i]
i = i + 1
print list1