Well here's a little example on how to use sortbyvalue, it seems tricky due to the lack of documentation but it's quite simple overall. (Didn't see cbk posted this already but oh well..)
The syntax provided by script help, edited for clarity. (On RC: /scripthelp sortbyvalue).
TGraalVar.sortbyvalue(str1, str2, boolean) - sorts an array.
str1: the variable of the array members which is compared
str2: variable type; variable type can be "string", otherwise it is sorted by floating point value
boolean: sort by ascending (I.e: 1 to 9) or not
Usage:
PHP Code:
function onCreated() {
// Initialize Example Array
temp.arr = {{"a", 33}, {"b", 11}, {"c", 22}};
// Loop through Array and specify Sortvalue
for (temp.a: temp.arr) {
// Stores the Number in Sortvalue
temp.a.sortvalue = temp.a[1];
}
// Sort by Value
temp.arr.sortbyvalue("sortvalue", null, true);
// Echo Sorted Array
for (temp.a: temp.arr) {
echo(temp.a[0] SPC temp.a[1]);
}
/*
Echos
b 11
c 22
a 33
*/
}
Like you posted above you can loop through your array that you created using getdynamicvarnames, and specify the sortvalue. So instead of using temp.a[1] like I did in the example you'd use the guild's/user's kills, which can be accessed like so:
PHP Code:
function onCreated() {
// Initialize Array and Kills Structure
this.guilds = {"a", "b", "c"};
this.guilds.a.kills = 100;
this.guilds.b.kills = 300;
this.guilds.c.kills = 50;
// Loop and Display Kills
for (temp.g: this.guilds) {
temp.kills = this.guilds.(@temp.g).kills;
echo(temp.g @ "'s kills: " @ temp.kills);
}
}