Raised This Month: $32 Target: $400
 8% 

2d Array Sorting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Antithasys
Moderator
Join Date: Apr 2008
Old 11-24-2008 , 18:11   2d Array Sorting
Reply With Quote #1

I am trying to sort a 2d array.

The array is an array of player indeces and float numbers.

Something like:
players[MAXPLAYERS + 1][1]

So it would have values like:
players[1][0] = index
players[1][1] = 1.65
players[2][0] = index
players[2][1] = 1.12
etc..

What I would like to do is sort the array in the 2nd demision with the index of 1.

Something like:
Sort all the numbers in players[][1] in a given order.

So then the value in players[1][0] would be the player index of the highest or lowest value for players[1][1].

Hope that made sense.
Antithasys is offline
BAILOPAN
Join Date: Jan 2004
Old 11-25-2008 , 04:35   Re: 2d Array Sorting
Reply With Quote #2

Use SortCustom2D, and provide a callback that implements the heuristics you want.

It's fast (quicksort) and avoids moving big chunks of data around.
__________________
egg
BAILOPAN is offline
Reply



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 12:10.


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