/hadd -sm Voting VoteA 0

This created an "item" in your hash table. You can get the individual items like:

//echo -a $hget(voting,votea)

but if you want to count how many items there are, you can use

//var %i $hfind(voting,vote*,0,w)

Then while %i is greater than zero, $hfind(voting,vote*,%i,w) gives you the name of each vote choice that matches the vote* wildcard. Now that this gives the name of the choice, you can use HGET to get the vote totals.

while (%i > 0) {
echo -a votes for choice $hfind(voting,vote*,%i,w) total is $hget(voting,$hfind(voting,vote*,%i,w) )
dec %i
}

By padding the vote totals with zero then combining with a text label, before putting them into the %results variable, it creates a text label that $sorttok could sort alphabetically. The reverse-sort I showed causes the "greatest" label to be sorted first, which puts the top vote getter at the top.

If you have 00123:VoteA as the top vote getter, you can use $gettok() to grab the first item, and use $left to grab the leftmost 5 digits as the zero-padded vote total, and $mid starting at the 7th position grabs the label instead. And you can display either as you see fit. You can loop through the votes or show them all. You may need to do some additional logic when you decide what to do when there's a tie for first place. Since the previous example had treated these totals as text labels, whichever one is alphabetically last gets reported as being the winner, because sorting in reverse order puts 00012:VoteB before 00012:VoteA.