I needed a simple sort for the words in a string and came up with this - hope 
it helps others.  There are probably better ways to do this so feel free to 
share:

/* ------------------ rexx ------------------------ *
| Simple bubble sort for words in a string (array) |
* ------------------------------------------------ */
  string = '10 0 1 9 6 2 4 3'
  do imx = 1 to words(string)-1
    do im = 1 to words(string)
      w1 = word(string,im)
      w2 = word(string,im+1)
      if w1 > w2 then do
        if im > 1
        then  lm = subword(string,1,im-1)
        else lm = ''
        rm = subword(string,im+2)
        string = lm w2 w1 rm
      end
    end
  end
  say string


--------------------------------------------------------------------------
Lionel B. Dyck
Mainframe Systems Programmer - TRA


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to