I have an array which contains a Month field which is just a string as below:
Array
(
[0] => stdClass Object
(
[id] => 1
[Month] => Jan-13
)
[1] => stdClass Object
(
[id] => 2
[Month] => Jan-14
)
[2] => stdClass Object
(
[id] => 3
[Month] => Jul-12
)
)
How can I sort this array into date order?
Thanks.
Obviously you need custom sorting so use usort. That leaves us with comparator. The not-that-pretty way might look like these:
example call:
You’d probably want to add some validation (if year might be before 2000, if the string is incorrect etc), but the above should roughly work.