Raised This Month: $ Target: $400
 0% 

Sorting an array


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-15-2012 , 20:47   Re: Sorting an array
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
1. Array sizes have to be constant and cannot be dependent on a variable.
If you need to have a dynamic array size, look into cell arrays.

2. You don't even need that list.
Code:
public cmdRank(id)  // Possibly replace nVault with SQL, makes sorting easier and more efficient {     if(get_pcvar_num(toggle_pcvar) == 0 || get_pcvar_num(frags_pcvar) )         return PLUGIN_CONTINUE             // devlop to MOTD listing of server-wide rank (connected players     new players[32], num     get_players(players, num, "ch")         SortCustom1D(players, num, "sortHelper")         // players are sorted         return PLUGIN_HANDLED } public sortHelper(const index1, const index2, const players[], const data[], const data_size) {     new diff = gi_playerFrags[players[index2]] - gi_playerFrags[players[index1]]         return (diff < 0) ? -1 : (diff ? 1 : 0) }
1. I only wanted it dynamic like that so i wouldn't have to have more cells then needed. But if its not possible, screw it.

2. wouldn't that change the frags for the players? because frags are stored in the cell index that correlates to their playerID, this would rearrange values, but not IDs. I need to keep both numbers together.

Though i must say....that return statement gives me a nerd-on.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode