You can use $iif(%num1 > %num2,%num1,%num2) for two numbers.
For more, you can use a tokenised list:
var %list = 10 25 18 7 256 11 9 | echo -a $gettok($sorttok(%list,32,nr),1,32)
The advantage here is that you can get the N largest entries by specifying 1-N for the $gettok index value
One way of saving the number of occurrences of items is with a hash table:
var %sentence the cat sat on the mat and on the mat it sat
var %n = $numtok(%sentence,32)
var %list
while (%n) {
var %word = $gettok(%sentence,%n,32)
hinc -m wordlist %word
dec %n
}
However using this with the above method for getting the max value would require a separate loop. Instead you could store the max value and compare it on each addition:
...
hinc -m wordlist %word
set %wordlist.max $+(%word,:,$hget(wordlist,%word))
...