题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
let str; while(str = parseInt(readline())){ getStr(str); } function getStr(str){ let resArr = []; for(let i = 0; i < str; i++){ let error = readline(); if(/[^a-zA-Z]/g.test(error)){ throw new Error('输入值错误'); } resArr.push(error); } //字符串也是能直接比较的 resArr.sort(function(a,b){ return a > b ? 1 : -1; }) console.log(resArr.join('\n')) }