I'm going to throw out this idea ... and realize I don't have an answer to your specific array situation. I think it would be a good idea to post your question in the MySQL section of this forum. Something in my gut tells me that most of what you're doing can actually be handled by the query itself. MySQL is way more powerful than many people give it credit for ... and someone with a lot of MySQL experience might be able to give you the definitive answer.
mlseim, thanks for the suggestion. I hadn't considered the possibility of doing some of the sorting through MySQL.
I'm going to leave this thread on here for a few days to see if anyone has any ideas to get my script working. I'd really like to figure out how to do this through PHP.
If nobody has an idea on whether/how it's possible, I'll try in the MySQL section of the forums.
Thanks again for the help everyone—I'm looking forward to hearing any suggestions for the script!