题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
let line = readline() let temparr = new Array(26).fill(0) let resultarr = [] for(let i = 0; i < 26; i++){ for(let j = 0; j < line.length; j++){ if(line.charCodeAt(j) - i == 65 || line.charCodeAt(j) - i == 97){ resultarr.push(line.slice(j,j+1)) } } } for(let i = 0; i < line.length; i++){ if(/[^A-Za-z]/.test(line.slice(i,i+1))){ resultarr.splice(i,0,line.slice(i,i+1)) } } console.log(resultarr.join(''))