home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1995 / ARCHIVE95.iso / discs / pipeline / 8_12 / Median / c_sort < prev    next >
Text File  |  1995-07-13  |  1KB  |  167 lines

  1. %OP%VS4.13 (28-Apr-92), Gerald L Fitton, R4000 5966 9904 9938 
  2. %OP%TNN
  3. %OP%WRN
  4. %OP%DP2
  5. %OP%IRN
  6. %OP%PL0
  7. %OP%HM0
  8. %OP%FM0
  9. %OP%BM0
  10. %OP%LM0
  11. %OP%FS0
  12. %OP%PT0
  13. %OP%WC2,1434,840,1748,0,0,0,0
  14. %OP%NDi,10
  15. %OP%NDj,11
  16. %OP%NDbiggest,F2
  17. %OP%NDbigrow,F3
  18. %OP%NDrange,E1E106
  19. %OP%NDtryj,E10
  20. %CO:A,24,72%%V%%L%function("sort","list:array")
  21.    \ expand the array into column E
  22. %V%%L%set_value(range,@list)
  23.  
  24.    \ scan down list & swap each row with biggest remaining row
  25. %V%%L%for("i",1,rows(@list)-1)
  26. %V%%L%   set_value(biggest,index(range,1,i))
  27.  
  28.       \find the biggest remaining
  29. %V%%L%   for("j",i,rows(@list))
  30. %V%%L%      set_name("tryj",index(range,1,j))
  31. %V%%L%      if(tryj > biggest,set_value(biggest,tryj),)
  32. %V%%L%      if(tryj=biggest,set_value(bigrow,j),)
  33. %V%%L%   next
  34.  
  35.       \change next line to numeric slot to watch swaps
  36.       alert(join(string(i)," ",string(bigrow)),"OK")
  37.  
  38.       \ now swap row i with row bigrow
  39. %V%%L%   set_value(F1,index(range,1,i))
  40. %V%%L%   set_value(index(range,1,i),biggest)
  41. %V%%L%   set_value(index(range,1,bigrow),F1)
  42.  
  43. %V%%L%next
  44. %V%%L%result(index(range,1,1,1,rows(@list)))
  45. %CO:B,12,60%%CO:C,18,48%%CO:D,12,36%%CO:E,6,24%%V%%R%103
  46. %V%%R%98
  47. %V%%R%97
  48. %V%%R%96
  49. %V%%R%93
  50. %V%%R%69
  51. %V%%R%66
  52. %V%%R%48
  53. %V%%R%21
  54. %V%%R%4
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. %V%%R%""
  159. %V%%R%"5"
  160. %V%%R%"4"
  161. %V%%R%"6"
  162. %V%%R%"2"
  163. %V%%R%"1"
  164. %CO:F,12,12%%V%%R%21
  165. %V%%R%21
  166. %V%%R%9
  167.