can somebody give me a working sorting algorithm. i cant seem to make any of the ones i found work.

i have this, but it doesn't work. it ain't getting past the while loop for some reason.

`Procedure InsertionSort(size : Integer);`

Var

i, j : Integer;

temp : Double;

Begin

For i := 2 to size-1 do

Begin

temp := KDarray[i];

j := i;

While (j > 1) AND (KDarray[j-1] > temp) do

Begin

KDarray[j] := KDarray[j-1];

j := j - 1;

end;

KDarray[j] := temp;

end;

End;