题解 | #输入整型数组和排序标识,对其元素排序#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
https://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { let length = await readline(); let input = await readline(); let condition = await readline(); input = input.split(' ').map((e)=> parseInt(e)); if(condition == 0){ input.sort((a, b) => a - b) } else if(condition == 1){ input.sort((a, b) => b - a) } console.log(input.join(' ')) // Write your code here // while(line = await readline()){ // let tokens = line.split(' '); // let a = parseInt(tokens[0]); // let b = parseInt(tokens[1]); // console.log(a + b); // } }()