mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-23 00:14:25 +00:00
38 lines
896 B
Plaintext
38 lines
896 B
Plaintext
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;
|
||
|