#!/usr/bin/tclsh proc reversewords {str} { proc rev {a b} {return 1} return [join [lsort -command rev [regexp -all -inline -- {\S+} $str]]] } puts "<<[reversewords { one two three four }]>>"