Anonymous user
Sorting algorithms/Permutation sort: Difference between revisions
Sorting algorithms/Permutation sort (view source)
Revision as of 23:33, 30 August 2017
, 6 years agoAdded Julia language
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
(Added Julia language) |
||
Line 856:
<lang sh>$ jq -c -n -f Permutation_sort.jq
[true,0,1,"too",{"a":0},{"a":1}]</lang>
=={{header|Julia}}==
<lang julia># v0.6
using Combinatorics
function permsort(x::Array)
for perm in permutations(x)
if issorted(perm)
return perm
end
end
end
x = randn(10)
@show x permsort(x)</lang>
{{out}}
<pre>x = [-0.799206, -2.52542, 0.677947, -1.85139, 0.744764, 1.5327, 0.808935, -0.876105, -0.234308, 0.874579]
permsort(x) = [-2.52542, -1.85139, -0.876105, -0.799206, -0.234308, 0.677947, 0.744764, 0.808935, 0.874579, 1.5327]</pre>
=={{header|Kotlin}}==
|