Is there a way to sort a multi-dimensional array?
Sorting Arrays
Started by falco85, Aug 15 2006 09:48 AM
5 replies to this topic
#1
Posted 15 August 2006 - 09:48 AM
|
|
|
#2
Posted 16 August 2006 - 03:38 PM
Yes. Now, what are your criteria for the array being "sorted"?
#3
Posted 16 August 2006 - 05:52 PM
Well I have an array that looks like this:
array[0] = "data1|data2|data3|data4";
array[1] = "data1|data2|data3|data4";
I need the array sorted by data3. The only way I can think of doing it is by cycling through the array - exploding it and then adding the data to another array. Is that right?
array[0] = "data1|data2|data3|data4";
array[1] = "data1|data2|data3|data4";
I need the array sorted by data3. The only way I can think of doing it is by cycling through the array - exploding it and then adding the data to another array. Is that right?
#4
Posted 23 August 2006 - 05:37 PM
It depends a little bit on whether you need to sort data1, data2, data4 in parallel with data3. If you need to sort data3 and not touch the others, I'd just pass data3 into your sort algorithm and be done.
Basicly, you need to find a "key" that you can sort linearly, and work everything off that as necessary.
Basicly, you need to find a "key" that you can sort linearly, and work everything off that as necessary.
#5
Posted 23 August 2006 - 06:06 PM
Did you ever figure this one out? I'd like to see the code results from it.
#6
Posted 23 August 2006 - 06:31 PM
The problem is that I don't know PHP. And I wasn't clear what exactly needs to get sorted.


Sign In
Create Account


Back to top









