This command will let you sort data in windows.
Syntax: /sortWin window token start end
(start and end are optional)
Items in the window will be sorted by the second token
eg. your token is 32 (ascii for space), and your window is
Thomas 16
Ashley 2
Johnny 8
(/sortWin @window 32) would reordered it as
Ashley 2
Johnny 8
Thomas 16
To test it, type use the /sort.test, then use /sortWin on @sW using token 32
This is handy for calculating ranking on a larger scale than what sorttok can handle.
Feel free to do whatever you want with it.
/*
Sort Window
Made by BlueThen on April 18, 2010
www.bluethen.com
Syntax: /winsrt window token start end
Items in the window will be sorted by the second token
eg. your token is 32 (ascii for space), and your window is
Thomas 16
Ashley 2
Johnny 8
(/sortWin @window 32) would reordered it as
Ashley 2
Johnny 8
Thomas 16
To test it, type use the /sort.test, then use /sortWin
*/
alias sortWin {
%token = $2
tokenize 32 $1 $iif($3, $3, 1) $iif($4, $4, $line($1, 0))
%i = $2
%k = $3
if ($calc($3 - $2) >= 1) {
%pivot = $gettok($line($1, $2), 2, %token)
while (%k > %i) {
while (($gettok($line($1, %i), 2, %token) <= %pivot) && (%i <= $3) && (%k > %i)) {
inc %i
}
while (($gettok($line($1, %k), 2, %token) > %pivot) && (%k >= $2) && (%k >= %i)) {
dec %k
}
if (%k > %i) {
swap $1 %i %k
}
}
swap $1 $2 %k
sort.con $1 %token $calc(%k + 1) $3
sort.con $1 %token $2 $calc(%k - 1)
}
}
alias -l swap {
%T = $line($1, $3)
rline $1 $3 $line($1, $2)
rline $1 $2 %T
}
alias -l sort.con {
sortWin $1-
}
alias sort.Test {
window -c @sw
window -e1k0z @sW
aline @sW Joey 3
aline @sW Kayla 14
aline @sW Phillip 19
aline @sW Sarah 7
aline @sW Ashley 2
aline @sW Johnny 8
aline @sW Bobby 2
aline @sW Thomas 16
}