How would I go about sorting a multi-dimenstional array?

For questions about using Classic.

Post » Wed Feb 03, 2010 4:21 pm

So I'm trying out some arrays and I would really like to know how I would sort the following array
array(family's Y co-ordinate, family's variable, UID if necessary)

So far it's proving to be a killer, I've looked up some sorting algorithms but I'm not too savvy on a lot of the lingo they use to define them. The sorting algorithms that looked nice were, bubble, gnome and possibly insert, I'm not sure how they apply to multi-dimensional arrays though.

I want the array to look something like this when it's sorted (leaving UID out for now):

5, 0
5, 1
5, 3
10, 0
10, 6
10, 8
etc

So primarily sorting by the Y co-ordinate ascending, but if any of the family have the same Y co-ordinate then sort by their private variable ascending

Is this possible at the moment? I'm assuming its to do with a bunch of nested loops, but it's 3:20am and my brain has imploded
Remember, I'm not that mathy, you'll have to translate into english for me :D
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Wed Feb 10, 2010 3:20 pm

For those that are interested, I got it working, however it didn't solve my problem so its back to the drawing board :(
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Wed Feb 10, 2010 11:41 pm

Yeah there really is no specific way to sort floats or integers, other than making up your own.
I wonder if its possible to have a object, or behavior that could do that for you.

Edit I suppose Lucid's S plug could do it, perhaps he could give an example of how that might work.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests