// This program is a simple example of sorting // an array. dim name$(100,3) dim first$ (20), last$(20) DATA Mary,John,Charles,Sue,Sam,Tom,Lily,Fred,Bob,Henry DATA Louise,Frank,Helen,Jerry,Will,Dave,Trudy,Jenny,Hank,Marge DATA Johnson,Smith,Jones,Wilson,Edwards DATA Porter,Murphy,Cooper,Chandler,Duncan, DATA MacArthur,Jackson,Franklin,Lincoln,Adams DATA Brown,Green,O'Reilly,Nelson,Harburg For i=0 to 19 read first$(i) next for i=0 to 19 read last$(i) next // Now generate random combinations of first and last names // and store them in the array. for i=0 to 99 name$(i,0)=first$(int(rnd(1)*20)) name$(i,1)=last$ (int(rnd(1)*20)) name$(i,2)=str$ (i, "###") next ? print "Print the names in original order" // Note: There may be duplicates ? for i=0 to 99 print name$(i,0),name$(i,1), name$(i,2) next // sort the array by first, then last sort name$,keycol1=0,keycol2=1 ? print "Print the names sorted by first name" // You can see by the sequence numbers, that the original // Sequence is preserved in the case of duplicates ? for i=0 to 99 print name$(i,0),name$(i,1), name$(i,2) next // sort the array by last, then first sort name$,keycol1=1,keycol2=0 ? print "Print the names sorted by last name" ? for i=0 to 99 print name$(i,0),name$(i,1), name$(i,2) next