题解 | #输入整型数组和排序标识,对其元素按照升序或降序进行排序#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
http://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
const num = readline(); const arr = readline().split(' '); const flag = readline(); const res = arr.map( num => +num).sort((a,b) => { if(flag == '0'){ return a-b }else if( flag == '1'){ return b-a } })
console.log(res.join(' '))