Thread: Sorting
View Single Post
  #19  
Old 11-22-2009, 04:15 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Switch View Post
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.gtemp.guildzname) {  
    
temp.g.kills this.guilds.(@temp.g).kills;  
  }
  
// Sort 
  
temp.guildzname.sortbyvalue("kills"nullfalse);
  
// Loop through Sorted Data
  
for (temp.0temp.5temp.i++) {
    
// Determine Variables
    
temp.temp.guildzname[temp.i];
    
temp.kills this.guilds.(@temp.g).kills;
    
temp.str = (temp."'s kills: " temp.kills);
    
// Add formatted string to data array
    
temp.data.add(temp.str);
  }
  
// Return the data array  
  
return temp.data;  

__________________
Quote:
Reply With Quote