Algorithm Implementation/Sorting/Insertion sort

Ada
Sorts an array of integers.

C/C++
In C:

In C++:

In C++, half insertion sort:

C# 2.0
This example sorts a list of objects of any type T that implements IComparable. It demonstrates C# 2.0 generics and in particular the "where" clause.

Fortran 90/95
This implementation of Insertion sort follows closely the implementation that can be found in the GPL FORTRAN 90/95 GPL library AFNL.

Java
another general implements.

shorter version
The insert function is the same as above.

Pascal
Linked list version

Standard ML
fun insertsort [] = [] | insertsort (x::xs) = let fun insert (x:real, []) = [x] | insert (x:real, y::ys) = if x<=y then x::y::ys else y::insert(x, ys) in insert(x, insertsort xs) end;

shorter version
The insert function is the same as above.

Ruby
It sorts the original array.

Swift
In Swift:

NASM
C prototype is

Assembler routine is

VB
And here's something a little bit quicker.

Implementazioni di algoritmi/Insertion sort Примеры реализации сортировки вставками