I have two arrays like below:
Array
(
[27119] => Array
(
[firstname] => Array
(
[0] => Testfname1
)
[lastname] => Array
(
[0] => Testlname1
)
[photograph] => Array
(
[0] => 27120
)
[priority] => Array
(
[0] => Open
)
[primary_location] => Array
(
[0] => 27098
)
)
[27137] => Array
(
[firstname] => Array
(
[0] => Testfname2
)
[lastname] => Array
(
[0] => Testlname2
)
[photograph] => Array
(
[0] => 27138
)
[priority] => Array
(
[0] => Featured
)
[primary_location] => Array
(
[0] => 27098
)
)
)
Now I want to sort the array based on the values of priority
key in such a way that, if it's value is Featured
then that whole element (the array containing that pair) should occur before(if there is no other candidate having 'priority => featured') the element containing 'priority => open' in the array. If it's value is Open
then it's parent array should be before the parent element containing 'priority => closed'.
So to sum up, I want to sort the given multidimensional array by "priotity" value and conditionally.
I thought of using usort, but I cannot get initial idea about how to set that in those array_sort functions. Can anyone help ?