题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
const line = readline()
const LEN = line.length
const nums = []
const others = []
let arr = new Array(26).fill('')
let res = ''
for(let i = 0; i < LEN; i++){
let codeValue = line[i].charCodeAt()
if((codeValue >= 65 && codeValue <= 90) || (codeValue >= 97 && codeValue <= 122)){
arr[line[i].toLowerCase().charCodeAt() - 97] += line[i]
}else{
others.push(line[i])
nums.push(i)
}
}
others.reverse()
arr = arr.join('').split('')
for(let i = 0; i <LEN; i++){
if(nums.includes(i)){
res+=others.pop()
}else{
res+=arr.shift()
}
}
console.log(res)