BBS: Inland Empire Archive Date: 03-24-92 (09:27) Number: 180 From: MATT HART Refer#: 41 To: RON HENDERSON Recvd: NO Subj: Problems with Sort and Ot Conf: (2) Quik_Bas
RH> I am having some problems sorting arrays. Specifically ones with three RH> elements or more. A$(i,j,k) for instance, is an array I am using to RH> input three pieces of data, Name, Address, and City for example. I think you have you method of storage wrong. To save data on 3 different items, Name, Address, City, you would use: INPUT "How many names";NumNames DIM A$(1 TO NumNames,1 TO 3) FOR i = 1 TO NumNames LINE INPUT "Enter name ";A$(i,1) LINE INPUT "Enter address ";A$(i,2) LINE INPUT "Enter city ";A$(i,3) NEXT i INPUT "Sort by (N)ame (A)ddress or (C)ity ?";B$ SELECT CASE UCASE$(B$) CASE "N" : El = 1 CASE "A" : El = 2 CASE "C" : El = 3 CASE ELSE : END END SELECT FOR i = 1 TO NumNames - 1 FOR j = i+1 TO NumNames IF UCASE$(A$(i,El)) > UCASE$(A$(j,El)) THEN SWAP A$(i,1),A$(j,1) SWAP A$(i,2),A$(j,2) SWAP A$(i,3),A$(j,3) ENDIF NEXT j PRINT "Name : ";A$(i,1) PRINT "Address : ";A$(i,2) PRINT "City : ";A$(i,3) PRINT NEXT i -+-- 'XRS 5.0 Offline Reader/Editor' Matt E. Hart, QB Guru --- * Origin: Midnight Micro! V.32/REL (918)451-3306 (1:170/600)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET