Largest int from concatenated ints: Difference between revisions

Updated to work with version 1.4 of Nim.
(Updated to work with version 1.4 of Nim.)
Line 1,293:
 
=={{header|Nim}}==
<lang nim>import algorithm, sequtils, strutils, futuresugar
 
proc maxNum(x: seq[int]): string =
var c = x.mapIt(string, $it)
c.sort((x, y) => cmp(y&x, x&y))
c.join()
Line 1,302:
echo maxNum(@[1, 34, 3, 98, 9, 76, 45, 4])
echo maxNum(@[54, 546, 548, 60])</lang>
 
{{out}}
<pre>998764543431
Anonymous user