RosettaCodeData/Task/Largest-int-from-concatenated-ints/JavaScript/largest-int-from-concatenated-ints-2.js

8 lines
190 B
JavaScript
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
var maxCombine = (a) => +(a.sort((x, y) => +("" + y + x) - +("" + x + y)).join(''));
// test & output
console.log([
[1, 34, 3, 98, 9, 76, 45, 4],
[54, 546, 548, 60]
].map(maxCombine));