After reading several posts here about this subject, I am unable to find the exact answer to my problem.
My current array is:
Array
(
[0] => Array
(
[Level] => Bronze
[Name] => JP Morgan
[Logo] => Logo
)
[1] => Array
(
[Level] => Bronze
[Name] => NASDAQ OMX
[Logo] => Logo
)
[2] => Array
(
[Level] => Platinum
[Name] => Credit Suisse
[Logo] => Logo
)
[3] => Array
(
[Level] => Silver
[Name] => BNP Paribas
[Logo] => Logo
)
)
What I want is to have all sponsors sorted by [Level]
of which the order is:
- Platinum
- Gold
- Silver
- Bronze
How do I do this?
You could define your own sorting function. For example, you'd specify your own custom order that you want it to follow:
Pass your array with all your data into your custom sort function, and search for the value's key position (in this case,
Level
) in the sort order you've just defined:Outputs: