Sorting algorithms/Insertion sort: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,731: | Line 1,731: | ||
print(unpack(isort{4,5,2,7,8,3}))</lang> |
print(unpack(isort{4,5,2,7,8,3}))</lang> |
||
=={{header|Maple}}== |
|||
<lang Maple>arr := Array([17,3,72,0,36,2,3,8,40,0]): |
|||
len := numelems(arr): |
|||
for i from 2 to len do |
|||
val := arr[i]: |
|||
j := i-1: |
|||
while(j > 0 and arr[j] > val) do |
|||
arr[j+1] := arr[j]: |
|||
j--: |
|||
end do: |
|||
arr[j+1] := val: |
|||
end do: |
|||
arr;</lang> |
|||
{{Out|Output}} |
|||
<pre>[0,0,2,3,3,8,17,36,40,72]</pre> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |