This should be fairly simple but my brain can't seem to process this at the moment. Hoping you can help :)
I have an array of posts that each have a tag, looks something like this:
Array(
[0] = Array('Computers', postObject),
[1] = Array('Sports', postObject),
[2] = Array('Computers', postObject),
[3] = Array('Business', postObject)
)
I was using asort()
which seemed to sort the posts alphabetically, but I now need to sort the posts based on a specified order (stored in an array) that might have extra values.
Array(
[0] = 'Sports',
[1] = 'Fashion',
[2] = 'Business',
[3] = 'Computers',
[4] = 'Stocks'
)
I'm expecting the first array to be sorted like this:
Array(
[0] = Array('Sports', postObject),
[1] = Array('Business', postObject),
[2] = Array('Computers', postObject),
[3] = Array('Computers', postObject)
)
I don't think there is a simple php function to call, can you please advise ?