You are viewing a single comment's thread. Return to all comments →
JS
function processData(input) { //Enter your code here const data = input.split('\n'); const arr = [] for (let i = 1; i < data.length; i++) { const [name, scores] = data[i].split(' '); arr.push([name, scores]) } const rr = obj.sort((a, b) => { if (b[1] !== a[1]) { return b[1] - a[1]; } return a[0].localeCompare(b[0]); }); const result = rr.map(r => r.join(' ')).join(' \n') console.log(result); }
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 →
JS