Sorting algorithms/Insertion sort: Difference between revisions
Sorting algorithms/Insertion sort (view source)
Revision as of 11:54, 23 December 2014
, 9 years ago→{{header|C sharp|C#}}
(+ second D entry) |
|||
Line 282:
=={{header|C sharp|C#}}==
<lang csharp>
using System;
static class InsertionSort<T> where T : IComparable {
Sort(entries, 0, entries.Length - 1);
class Program▼
▲ static void Main(string[] args)
{▼
int[] A = new int[] { 3, 9, 4, 6, 8, 1, 7, 2, 5 };▼
Console.WriteLine(string.Join(",", A));▼
}▼
var entry =
while (j > first && entries[j - 1].CompareTo(entry)
entries[j] =
}
}
}</lang>
'''Example''':
<lang csharp> using Sort;
using System;
static void Main(String[] args) {
InsertionSort<Int32>.Sort(entries);
}</lang>
=={{header|Clojure}}==
Translated from the Haskell example:
|