alias top3 {
var %N1 | var %N2 | var %N3
var %Index 1 | var %Nick | var %Data
; Make hashtable
hadd -m hashfind OuTsIdErS 3
hadd hashfind Joshey 8
hadd hashfind Bo 2
hadd hashfind Moe 12
hadd hashfind Hoe 11
hadd hashfind Pimp 9
hadd hashfind Mamamia 3
hadd hashfind Jonboi 15
; Find Top 3
set %Nick $hfind(hashfind, *, %Index, w)
while (%Nick != $null) || (%Index == 1) {
set %Data $hget(hashfind, %Nick)
if (%N1 == $null) { set %N1 %Nick %Data }
else {
if (%N2 == $null) {
if ($num(%N1) < %Data) { set %N2 %N1 | set %N1 %Nick %Data }
else { set %N2 %Nick %Data }
}
else {
if (%N3 == $null) {
if ($num(%N1) < %Data) { set %N3 %N2 | set %N2 %N1 | set %N1 %Nick %Data }
else if ($num(%N2) < %Data) { set %N3 %N2 | set %N2 %Nick %Data }
else { set %N3 %Nick %Data }
}
else {
if ($num(%N1) < %Data) { set %N3 %N2 | set %N2 %N1 | set %N1 %Nick %Data }
else if ($num(%N2) < %Data) { set %N3 %N2 | set %N2 %Nick %Data }
else if ($num(%N3) < %Data) { set %N3 %Nick %Data }
}
}
}
inc %Index | set %Nick $hfind(hashfind, *, %Index, w)
}
; Display Results
echo -a 1st Place went to $gettok(%N1, 1, 32) with a score of $gettok(%N1, 2, 32)
echo -a 2nd Place went to $gettok(%N2, 1, 32) with a score of $gettok(%N2, 2, 32)
echo -a 3rd Place went to $gettok(%N3, 1, 32) with a score of $gettok(%N3, 2, 32)
.hfree hashfind
}
alias num { return $gettok($1, 2, 32) }