/* Rexx Lab Exercise 3 - Session G52-G53 */

rank='2 3 4 5 6 7 8 9 10 J Q K A'

parse arg hand
num=words(hand)

do i=1 to num
  parse var hand item.i hand
  say hand
end

do i=1 to num
  do j=i+1 to num
    if wordpos(item.j, rank) > wordpos(item.i,rank)
       then do
       temp=item.j
         item.j=item.i
         item.i=temp
       end
    end j
    hand = hand item.i
end

say hand
