Inside3D!
     

Quake C sort?

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
DieparBaby



Joined: 05 Dec 2006
Posts: 44
Location: London, Ontario, Canada, eh

PostPosted: Mon Dec 18, 2006 4:10 pm    Post subject: Quake C sort? Reply with quote

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
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Mon Dec 18, 2006 7:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
DieparBaby



Joined: 05 Dec 2006
Posts: 44
Location: London, Ontario, Canada, eh

PostPosted: Mon Dec 18, 2006 8:26 pm    Post subject: Reply with quote

Thank you Spike.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group