' This program reads a list of strings (words) ' from the user and orders it (sorts it) ' in ascending order CLS ' Declare variables DIM n, i, j AS INTEGER DIM t AS STRING ' Data input PRINT "Give n: "; INPUT n DIM dat(n) AS STRING FOR i = 1 TO n PRINT "Give No "; i INPUT dat(i) NEXT ' sort the elements FOR i = 1 TO n - 1 ' the inner for loop below ensures that, after it finishes, ' the contents of dat(i) are correct and they will not change from then on FOR j = i + 1 TO n IF dat(i) > dat(j) THEN t = dat(i) dat(i) = dat(j) dat(j) = t END IF NEXT NEXT ' print the results FOR i = 1 TO n PRINT dat(i) NEXT