Hash tables aren't meant to be sorted, it's a structure that offers fast retrieval of items but no form of ordering/sorting. However, you can /hsave the table to a temp file (using the -i switch, to save it in an .ini format) and sort the file itself with /filter. This is fast enough, far faster than looping through the hash table items. For example, if you want to get the highest/lowest number in the table called "blah" you can use something like this:
.remove temp.htb
hsave -i blah temp.htb
filter -ffcuter 2-999999 2 61 temp.htb temp.htb
var %high = $read(temp.htb,n,1), %low = $read(temp.htb,n,$filtered)
echo -a Item $gettok(%high,1,61) has the highest number: $gettok(%high,2,61)
echo -a Item $gettok(%low,1,61) has the lowest number: $gettok(%low,2,61)
This is a descending (-e), numeric (-u) sorting of the 2nd column, using the "=" character (ascii number 61) as the column separator (-t 2 61). After running this code, type
/run notepad temp.htb
and take a look at the contents of the file to better understand what's happened.