You are viewing a single comment's thread. Return to all comments →
Javascipt
function processData(input) { //Enter your code here const arr = input.split("\n") const result = [] for (let i = 1; i < arr.length; i++) { result.push(arr[i].split(" ")) } result.sort((a, b) => { return b[1] - a[1]; }); result.sort((a, b) => { if (b[1] === a[1] && b[0] > a[0]) { return -1; } }); console.log(result.join("\n").replaceAll(",", " ")); }
Seems like cookies are disabled on this browser, please enable them to open this website
Sorting: Comparator
You are viewing a single comment's thread. Return to all comments →
Javascipt