home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1984 January to June / Ahoy_Magazine_84-Jan-Jun_1984_Double_L.d64 / array3 (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  353b  |  17 lines

  1. 0 rem--ahoy!--may issue--arrays--prog page 69
  2. 5 n=4
  3. 10 for i=1 to n:read n$(i),a(i):next i
  4. 20 data amy,25,abe,12,arthur,30,anne,5
  5. 30 rem - sort by name -
  6. 40 for i=1 to n
  7. 50 for j=i to n
  8. 60 if n$(i)>n$(j) then gosub 1000
  9. 70 next j
  10. 80 next i
  11. 90 for i=1 to n:print n$(i),a(i):next
  12. 100 end
  13. 990 rem - swap names and ages -
  14. 1000 t$=n$(i):n$(i)=n$(j):n$(j)=t$
  15. 1010 t=a(i):a(i)=a(j):a(j)=t
  16. 1020 return
  17.