Quote:
Originally Posted by Switch
Jer, I think you were a little messed up with your loop and setting the variable as temp.g.kills, because based off what Chris posted you need to save it as a subvariable in the array, though I've never used array.sortbyvalue() before.
|
The code I posted works, as I tested it successfully.
This is basically what you'll need, you've tried enough to deserve it.
PHP Code:
public function getTop5() {
// Initialize Array and Kills Structure
temp.guildzname = getGuildList();
// Loop and Record Kills in the Array Member's sort variable
for (temp.g: temp.guildzname) {
temp.g.kills = this.guilds.(@temp.g).kills;
}
// Sort
temp.guildzname.sortbyvalue("kills", null, false);
// Loop through Sorted Data
for (temp.i = 0; temp.i < 5; temp.i++) {
// Determine Variables
temp.g = temp.guildzname[temp.i];
temp.kills = this.guilds.(@temp.g).kills;
temp.str = (temp.g @ "'s kills: " @ temp.kills);
// Add formatted string to data array
temp.data.add(temp.str);
}
// Return the data array
return temp.data;
}