View previous topic :: View next topic |
Author |
Message |
DieparBaby

Joined: 05 Dec 2006 Posts: 44 Location: London, Ontario, Canada, eh
|
Posted: Mon Dec 18, 2006 4:10 pm Post subject: Quake C sort? |
|
|
As an example, I'd like to sort a set of entities with the classname "player" by their .frags field and then print out at least some of the list to each client. It doesn't seem possible but maybe someone smarter has written a sort function in quake c. Anyone know?
Thanks,
DieparBaby |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Mon Dec 18, 2006 7:42 pm Post subject: |
|
|
An insertion sort is probably best.
First, build a chain of them, then while there are still ents in that chain find the highest score and copy it over to a new chain and remove them from the old, inserting at the end of the new chain.
The new chain will then be sorted.
You can then loop through the new chain and print them as you go.
There are no builtins or anything to do this for you. _________________ What's a signature? |
|
Back to top |
|
 |
DieparBaby

Joined: 05 Dec 2006 Posts: 44 Location: London, Ontario, Canada, eh
|
Posted: Mon Dec 18, 2006 8:26 pm Post subject: |
|
|
Thank you Spike. |
|
Back to top |
|
 |
|