Largest int from concatenated ints: Difference between revisions

D entry: maxCat3 is now less elegant but works with [10, 1010]
m (→‎{{header|REXX}}: added comment in the REXX section header. -- ~~~~)
(D entry: maxCat3 is now less elegant but works with [10, 1010])
Line 70:
=={{header|D}}==
The three algorithms. Uses the second module from the Permutations Task.
<lang d>import std.stdio, std.algorithm, std.stringconv, std.convarray, permutations2;
 
auto maxCat1(in int[] arr) {
Line 80:
}
 
auto maxCat3(in int[] arr) {
immutable maxl = arr.reduce!max.text.length;
in {
return arr.to!(string[])
assert(arr.dup.sort().equal(arr.dup.sort().uniq), "Not distinct");
.schwartzSort!(s => s.replicate(maxl/s.length + 1), "a > b")
} body {
return arr.to!(string[]).sort!q{cmp(a.cycle, b.cycle) > 0} .join;
}