The simplest way is to create a sorted hidden window, add all the lines from [Nicks] in the form value item; then just work backwards from the end of $line(@window,%i) to get the highest down to the lowest (or as far as you wish to go.
Code:

  [color:#006600]
  ;  Create the hidden sorted window.
  ;[/color]
  window -sh @Sorted
  [color:#006600]
  ;  Create a variable to hold the filename so you don't have to keep resolving it.
  ;[/color]
  var %ini = $+(stats.,$chan,.user.ini)
  [color:#006600]
  ;  Find out how many values are in the [Nicks] section so we'll know how many
  ;  0's to left-pad with to ensure proper sorting order.
  ;[/color]
  var %0Pad = $str(0, $len($ini(%ini, Nicks, 0)))
  [color:#006600]
  ;  Create the loop index.
  ;[/color]
  var %i = 1
  [color:#006600]
  ;  Work through each of the nicks in the [Nicks] section.
  ;[/color]
  while ($ini(%ini, Nicks, %i)) {
  [color:#006600]
    ;  Save the line in a variable so you can switch the order without having to re-read the file.
    ;[/color]
    var %line = $readini(%ini, Nicks, $ifmatch)
  [color:#006600]
    ;  Add each nick=lines backwards, in the form: lines nick. We will also need to 0-pad the
    ;  number in order to get them to sort correctly.
    ;[/color]
    aline @Sorted $right($+(%0Pad,$gettok(%line, 2, 32)), $len(%0Pad)) $gettok(%line, 1, 32)
  [color:#006600]
    ;  Go on to the next nick, if there is one.
    ;[/color]
    inc %i
  }
  [color:#006600]
  ;  At this point, the @Sorted window contains all the lines nicks in sorted order.
  ;[/color]
  [color:#006600]
  ;  Unset the old top15 variables, if any.
  ;[/color]
  unset %stats.top15.user*
  [color:#006600]
  ;  Create the variable to be used to increment the .userN value.
  ;[/color]
  var %j = 1
  [color:#006600]
  ;  Set %i equal to the last line number of the @Sorted window, to work backwards through it.
  ;[/color]
  %i = $line(@Sorted, 0)
  [color:#006600]
  ;  Loop through @Sorted backwards.
  ;[/color]
  while ($line(@Sorted, %i)) {
  [color:#006600]
    ;  Set the %stats.top15.userN equal to the nick and the un-0padded number.
    ;  Remove the 0 padding by adding 0 to the number.
    ;[/color]
    set $+(%,stats.top15.user,%j) $gettok($line(@Sorted,%i), 2, 32) $calc($gettok($line(@Sorted,%i), 1, 32) + 0)
  [color:#006600]
    ;  Increment the userN number
    ;[/color]
    inc %j
  [color:#006600]
    ;  Check to see if we've exceeded the 15 we want; if so, drop out of the loop.
    ;[/color]
    if (%j > 15) break
  [color:#006600]
    ;  Go to the previous line in @Sorted, if any exists.
    ;[/color]
    dec %i
  }
  [color:#006600]
  ;  At this point, you will have created all of your %stats.top15.userN variables with their values = nick lines.
  ;[/color]



DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C