Here is a sort routine that uses the Selection Sort method, rather than mIRC's $sorttok. It does not support multiple words; you can call it from within a loop to sort multiple words.

Code:

alias sort {
  tokenize 32 $$1-
  var %s = $1
  var %hname = $+(asort.,$ticks)
  if ($hget(%hname)) hfree %hname
  var %i = 0, %ii = $len(%s)
  while (%i < %ii) {
    inc %i
    hadd -m %hname $+(s.,%i) $asc($mid(%s,%i,1))
  }
  var %x, %i = 0, %ii = $calc($len(%s) - 1)
  while (%i < %ii) {
    inc %i
    %x = %i
    var %j = %i, %jj = $calc(%ii + 1)
    while (%j < %jj) {
      inc %j
      if ($hget(%hname,$+(s.,%x)) >= $hget(%hname,$+(s.,%j))) { %x = %j }
    }
    var %t = $hget(%hname,$+(s.,%i))
    hadd %hname $+(s.,%i) $hget(%hname,$+(s.,%x))
    hadd %hname $+(s.,%x) %t
  }
  var %ss, %i = 0, %ii = $len(%s)
  while (%i < %ii) {
    inc %i
    %ss = $+(%ss,$chr($hget(%hname,$+(s.,%i))))
  }
  $iif($isid,return,echo -a) %ss
  hfree %hname
}



/sort <word>
$sort(<word>)

The code has to use hash tables, because mIRC doesn't support arrays.

-genius_at_work