I know there have been many posts regarding array sorting, but I have looked high and low and cannot find a solution to my problem.
I have found a very good article here: http://firsttube.com/read/sorting-a-multi-dimensional-array-with-php/
The above link is great, however, I wish to take it further and sort the array subkey based off the order of another array.
So, let’s say we have five songs in the Playlist Array:
Array
(
[0] => 3oh!3 - Don't Trust me
[1] => Taylor Swift - You Belong with me
[2] => Sean Kingston - Fire Burning
[3] => Green Day - Know Your Enemy
[4] => Kelly Clarkson - Gone
)
And let’s say we have the following information that we would like sorted to match the order of our Playlist Array:
[code]Array
(
[0] => Array
(
[trackName] => Taylor Swift - You Belong With Me
[trackLength] => 0
[trackViews] => 0
[trackRating] => 0
)
[1] => Array
(
[trackName] => Sean Kingston - Fire Burning
[trackLength] => 0
[trackViews] => 0
[trackRating] => 0
)
[2] => Array
(
[trackName] => 3OH!3- Dont Trust Me
[trackLength] => 205
[trackViews] => 4570399
[trackRating] => 4.866372
)
[3] => Array
(
[trackName] => Green Day Know Your Enemy
[trackLength] => 191
[trackViews] => 4715494
[trackRating] => 4.9103785
)
[4] => Array
(
[trackName] => Kelly Clarkson: Gone
[trackLength] => 225
[trackViews] => 679019
[trackRating] => 4.8995433
)
)
[/code]
So, again… My question is: How can I get the array of songs to be sorted by the trackName to match the same order of the Playlist Array?
Any help or guidance would be appreciated!
Thanks,
Rygotype