8-Bit Software Online Conversion

:0.B.COUNT2 - Listing

10REM COUNTED SORT 20REM BY HUGH STUART WILLIAMS 1990 30MODE7:VDU23;8202;0;0;0; 40@%=&50506 50ONERRORREPORT:PRINT" at line ";ERL: END 60size%=15 70max%=255 80seed%=1 90IF max%>size% THEN val%=max% ELSE v al%=size% 100DIM items%(size%) 110DIM count%(val%) 120DIM position%(size%) 130PROCclear`totals 140PROCrandomize 150PROCshow`data 160PROCcounted`sort 170PROCshow`data 180END 190: 200DEFPROCclear`totals 210FOR loop%=0 TO max% 220count%(loop%)=0 230NEXT loop% 240ENDPROC 250: 260DEFPROCrandomize 270seed%=RND(-seed%) 280FOR loop%=0 TO size% 290items%(loop%)=RND(max%+1)-1 300position%(loop%)=0 310NEXT loop% 320ENDPROC 330: 340DEFPROCshow`data 350CLS:PRINT'" Counted sort routine. " ' 360PRINT" Initial Sorted" 370PRINT" List List" 380FOR loop%=0 TO size% 390PRINTitems%(loop%),position%(loop%) ,count%(loop%) 400NEXT loop% 410PRINT'" <SPACE> " 420REPEAT:UNTIL GET=32 430ENDPROC 440: 450DEFPROCcounted`sort 460FOR loop%=0 TO size% 470count%(items%(loop%))=count%(items% (loop%))+1 480NEXT loop% 490: 500FOR loop%=1 TO max% 510count%(loop%)=count%(loop%)+count%( loop%-1) 520NEXT loop% 530: 540FOR loop%=size% TO 0 STEP-1 550position%(loop%)=count%(items%(loop %))-1 560count%(items%(loop%))=count%(items% (loop%))-1 570NEXT loop% 580: 590FOR loop%=0 TO size% 600count%(position%(loop%))=items%(loo p%) 610NEXT loop% 620ENDPROC