You are viewing a single comment's thread. Return to all comments →
Javascript - The trick is using same sort function for both sorts. Remember to console log the result --> console.log(input.join("\n"))
function processData(input){ input = input.split("\n"); input.shift(); input.sort((a,b) => { a = a.split(" "); b = b.split(" "); if(a[1] === b[1]){ return a[0] > b[0] ? 1 : -1; }else{ return b[1] - a[1]; } } );
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 →
Javascript - The trick is using same sort function for both sorts. Remember to console log the result --> console.log(input.join("\n"))