Sorting algorithms/Insertion sort: Difference between revisions

m
More logical variable names, and PL/I can use lowercase (since about 1964)
m (→‎{{header|AppleScript}}: Minor modification to take range parameters. Output shown in separate box.)
m (More logical variable names, and PL/I can use lowercase (since about 1964))
Line 3,055:
=={{header|PL/I}}==
<lang pli>
insert_sort: proc(array);
INSSORT: PROC(A);
dcl DCL Aarray(*) fixed FIXED BINbin(31);
DCLdcl (Ii,Jj,Vtmp,Nh,Ml) FIXEDfixed BINbin(31);
 
Nl = HBOUNDlbound(Aarray,1); M = LBOUND(A,1);
h DO I=M+1 TOhbound(array, N1);
 
V=A(I);
do i DO J=I-1 BY -1l WHILE+ (J>M-1 &to A(J)>V)h;
tmp = A(J+1)=Aarray(Ji);
 
END;
do j = i - 1 by -1 while(j > l - 1 & array(j) > tmp);
A(J+1)=V;
array(j + 1) = array(j);
END;
RETURN end;
 
END INSSORT;
Aarray(Jj + 1) =V tmp;
ENDend;
end insert_sort;
</lang>
 
Anonymous user