Sorting algorithms/Permutation sort: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 970:
{{out}}
<pre>1 2 3</pre>
 
=={{header|Maple}}==
<lang Maple>arr := Array([17,0,-1,72,0]):
len := numelems(arr):
P := Iterator:-Permute(len):
for p in P do
lst:= convert(arr[sort(convert(p,list),output=permutation)],list):
if (ListTools:-Sorted(lst)) then
print(lst):
break:
end if:
end do:</lang>
{{Out|Output}}
<pre>[-1,0,0,17,72]</pre>
 
=={{header|Mathematica}}==
Anonymous user