I have an array similar in design to the following:
Array
(
[0] => apple
[1] => Pear
[2] => orange
[3] => mango
[4] => [banana]
[5] => Cantaloupe
[6] => Peach
)
I need to have it sorted so it will output more like:
Array
(
[4] => [banana]
[0] => apple
[5] => Cantaloupe
[3] => mango
[2] => orange
[6] => Peach
[1] => Pear
)
Meaning I need results in []
listed first, and the rest sorted alphabetically not case sensitive.
I tried natcasesort
but that seems to have issues with []
.
How exactly would I get the results I am looking for keeping in mind this is an example array and results starting with [
are not always the 4th result nor is the result name actually [banana]