home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine 1995
/
ARCHIVE95.iso
/
discs
/
pipeline
/
8_12
/
Median
/
c_sort
< prev
next >
Wrap
Text File
|
1995-07-13
|
1KB
|
167 lines
%OP%VS4.13 (28-Apr-92), Gerald L Fitton, R4000 5966 9904 9938
%OP%TNN
%OP%WRN
%OP%DP2
%OP%IRN
%OP%PL0
%OP%HM0
%OP%FM0
%OP%BM0
%OP%LM0
%OP%FS0
%OP%PT0
%OP%WC2,1434,840,1748,0,0,0,0
%OP%NDi,10
%OP%NDj,11
%OP%NDbiggest,F2
%OP%NDbigrow,F3
%OP%NDrange,E1E106
%OP%NDtryj,E10
%CO:A,24,72%%V%%L%function("sort","list:array")
\ expand the array into column E
%V%%L%set_value(range,@list)
\ scan down list & swap each row with biggest remaining row
%V%%L%for("i",1,rows(@list)-1)
%V%%L% set_value(biggest,index(range,1,i))
\find the biggest remaining
%V%%L% for("j",i,rows(@list))
%V%%L% set_name("tryj",index(range,1,j))
%V%%L% if(tryj > biggest,set_value(biggest,tryj),)
%V%%L% if(tryj=biggest,set_value(bigrow,j),)
%V%%L% next
\change next line to numeric slot to watch swaps
alert(join(string(i)," ",string(bigrow)),"OK")
\ now swap row i with row bigrow
%V%%L% set_value(F1,index(range,1,i))
%V%%L% set_value(index(range,1,i),biggest)
%V%%L% set_value(index(range,1,bigrow),F1)
%V%%L%next
%V%%L%result(index(range,1,1,1,rows(@list)))
%CO:B,12,60%%CO:C,18,48%%CO:D,12,36%%CO:E,6,24%%V%%R%103
%V%%R%98
%V%%R%97
%V%%R%96
%V%%R%93
%V%%R%69
%V%%R%66
%V%%R%48
%V%%R%21
%V%%R%4
%V%%R%""
%V%%R%"5"
%V%%R%"4"
%V%%R%"6"
%V%%R%"2"
%V%%R%"1"
%CO:F,12,12%%V%%R%21
%V%%R%21
%V%%R%9