Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
Sorting algorithms/Insertion sort (view source)
Revision as of 03:02, 25 January 2009
, 15 years agoModula-3
m (Modula-3) |
|||
Line 221:
}
}
</code>
=={{header|Modula-3}}==
{{trans|Ada}}
<code modula3>
MODULE InsertSort;
PROCEDURE IntSort(item: ARRAY OF INTEGER) =
VAR j, value: INTEGER;
BEGIN
FOR i := FIRST(item) + 1 TO LAST(item) DO
value := item[i];
j := i - 1;
WHILE j >= FIRST(item) AND item[j] > value DO
item[j + 1] := item[j];
DEC(j);
END;
item[j + 1] := value;
END;
END IntSort;
END InsertSort.
</code>
|