Hello everyone,
This is my premiere post here, and I look forward to hearing from you all.
I'm currently developing a web application and am stuck at a very complicated spot. Here's the problem:
I have events that I'm pulling from a database and putting on a table. There are arrays that represent each attribute of the events (i.e. $Starttime is an array of all the start times). I have 6 or so arrays like that. So for event 1, $Starttime[1], $Endtime[1], etc. is put on the table. I hope that makes sense.
Now, I want to be able to sort these events by any and all of the variables. I'm not sure how to sort one array and maintain the key. So if I sort for $Starttime, $Starttime[1] might not correspond to $Endtime[1] anymore. How can I keep all the events related post-sort?
What is the best strategy for this?
Complicated Sort for multiple arrays
Started by Greelmo, Aug 11 2009 01:01 PM
3 replies to this topic
#1
Posted 11 August 2009 - 01:01 PM
|
|
|
#2
Posted 11 August 2009 - 01:07 PM
It sounds like you need an array of pairs of times, rather than two arrays of times.
#3
Posted 11 August 2009 - 01:10 PM
Hey Panther,
I believe that would be the solution if i were to only sort by time. However, there's a category attribute, a distance attribute, etc. all under that same key system and I want to be able to sort by each attribute independently.
Thanks,
-Greelmo
I believe that would be the solution if i were to only sort by time. However, there's a category attribute, a distance attribute, etc. all under that same key system and I want to be able to sort by each attribute independently.
Thanks,
-Greelmo
#4
Posted 12 August 2009 - 03:17 AM
What I would do is have an array of tuples. Then, have a modified sort routine that will allow you to select which item in the tuples to use as the sort key.


Sign In
Create Account

Back to top









