This might be coded more neat... but so far it works smile
Code:
alias banstats {
  if (#$1 !ischan) { echo -a you have to specity a valid chan, use /banstats #channelname }
  else {
    var %b.nr = 1, %v.nr = 1, %o.nr = 1, %list, %ouput

    ; loop the $ibl, set (or inc) a variable for each nick that set a ban
    while $gettok($ibl(#$1,%b.nr).by,1,33) {
      inc -u $+(%,banstats.,$ifmatch)
      inc %b.nr
    }

    ; loop the "individual" variables set, and store them in a single variable (make string that can be sorted)
    while ($var(banstats.*,%v.nr)) {
      var %list = $addtok(%list,$+($($v1,2),$chr(149),$gettok($v1,2,46)),32)
      inc %v.nr
    }

    ; sort the string with sorttok
    var %list = $sorttok(%list,32,r)

    ; finally, loop the string to get the intended output-design, add percentages
       while ($gettok(%list,%o.nr,32)) {
      var %output = $addtok(%output,$+($gettok($v1,2,149),: $gettok($v1,1,149) $iif(($gettok($v1,1,149) == 1),ban,bans) $&
        $chr(40),$round($calc($gettok($v1,1,149) / $ibl(#$1,0) *100),0),$chr(37),$chr(41)),32)
      inc %o.nr
    }
    echo -a Banstats for #$1 $+ : %output

  }
}