Sorting algorithms/Insertion sort: Difference between revisions
Content added Content deleted
Line 2,555: | Line 2,555: | ||
<pre>[0,0,2,3,3,8,17,36,40,72]</pre> |
<pre>[0,0,2,3,3,8,17,36,40,72]</pre> |
||
=={{header|Mathematica}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
<lang Mathematica>insertionSort[a_List] := Module[{A = a}, |
<lang Mathematica>insertionSort[a_List] := Module[{A = a}, |
||
For[i = 2, i <= Length[A], i++, |
For[i = 2, i <= Length[A], i++, |
||
Line 2,563: | Line 2,563: | ||
A |
A |
||
]</lang> |
]</lang> |
||
{{out}} |
|||
<pre>insertionSort@{ 2, 1, 3, 5} |
<pre>insertionSort@{ 2, 1, 3, 5} |
||
{1, 2, 3, 5}</pre> |
{1, 2, 3, 5}</pre> |