Sort an integer array: Difference between revisions

m
(added standard ml)
Line 72:
end Integer_Sort;
</lang>
=={{header|ALGOL 68}}==
{{trans|python}}
 
{{works with|ALGOL 68|Standard - no extensions to language used}}
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}}
<lang algol>CO PR READ "shell_sort.a68" PR CO
MODE TYPE = INT;
 
PROC in place shell sort = (REF[]TYPE seq)REF[]TYPE:(
INT inc := ( UPB seq + LWB seq + 1 ) OVER 2;
WHILE inc NE 0 DO
FOR index FROM LWB seq TO UPB seq DO
INT i := index;
TYPE el = seq[i];
WHILE ( i - LWB seq >= inc | seq[i - inc] > el | FALSE ) DO
seq[i] := seq[i - inc];
i -:= inc
OD;
seq[i] := el
OD;
inc := IF inc = 2 THEN 1 ELSE ENTIER(inc * 5 / 11) FI
OD;
seq
);
PROC shell sort = ([]TYPE seq)[]TYPE:
in place shell sort(LOC[LWB seq: UPB seq]TYPE:=seq);
 
print((shell sort((2, 4, 3, 1, 2)), new line))</lang>
Output:
<pre>
+1 +2 +2 +3 +4
</pre>
 
=={{header|APL}}==