Let’s say we have an array of objects like so that are coded incrementally like so: OBJ1, OBJ2, OBJ3..
One problem with MySQL is that there’s no easy way to naturally sort a returned array, so if you have 15 objects, you’ll end up with an array like:
The problem is that MySQL is sorting the keys in the manner of a computer, not a human. Not desirable.
Luckily, we’ve got the benefit of naturally sorting things as a human would.
Use the following function to sort the array by a nested key (such as “key” in the example above)
Enjoy :)