Files
Digital-Research-Source-Code/MPM OPERATING SYSTEMS/MPM-86/MISC DRI DISKS/10/SORT.PLI
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

38 lines
896 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

sort:
proc options(main);
dcl
(input_file, output_file) file;
open file (input_file) stream title ('b:x.lib');
open file (output_file) stream output title ('b:y.lib');
dcl
b char (64) var,
i fixed,
switching bit,
buff (250) char (64) var,
bp fixed;
on endfile(input_file)
go to sort_buff;
bp = 0;
do while ('1'b);
get file(input_file) edit(buff(bp+1))(a);
bp = bp + 1;
end;
sort_buff:
switching = '1'b;
do while (switching);
switching = '0'b;
do i = 1 to bp - 1;
if (buff(i) < buff(i + 1)) then
do;
switching = '1'b;
b = buff(i);
buff(i) = buff(i+1);
buff(i+1) = b;
end;
end;
end;
do i = 1 to bp;
put file(output_file) edit(buff(i),'')(a,skip,a);
end;
end sort;