Compucolor.org – Virtual Media

Listing of file='SORTNM.BAS;01' on disk='vmedia/demos-sector.ccvf'

2 PLOT 12
5 X= 1:S= 0
10 READ A$(X)
20 IF A$(X)< > "ZZZ"THEN X= X+ 1:GOTO 10
22 X= X- 1
24 PRINT :PRINT :PRINT :PRINT
25 PRINT "UNSORTED"
30 FOR Y= 1TO X
40 PRINT A$(Y),
50 NEXT Y
60 REM
61 PRINT :PRINT :PRINT :PRINT
65 PRINT "SORTING",
70 FOR Y= 1TO X- 1
80 FOR Z= YTO X
90 IF A$(Y)< A$(Z)THEN 120
100 T$= A$(Z)
110 A$(Z)= A$(Y)
115 A$(Y)= T$
117 S= S+ 1
120 NEXT Z
130 NEXT Y
135 PRINT S;" SWAPS MADE"
140 REM
142 PRINT :PRINT :PRINT :PRINT
145 PRINT "SORTED"
150 FOR Y= 1TO X
160 PRINT A$(Y),
170 NEXT Y
200 DATA JOHN,RUSSELL,MIKE,MICHAEL,LOUISE,FRED,FREDDY
210 DATA ZZZ