Arrays are a great way to store / work with data. In PHP, arrays are one of the most powerful data types of available. From time to time, you need to sort an array in reverse order. Of course, PHP has you covered:
Great, the array values are now sorted in reverse order. But wait?! The keys for those values have been reset! What are we to do? Again, PHP has you covered:
BOOM! Now the array values are sorted in reverse order and the keys have been retained. This can be very important when you are utilizing both the array’s values as well as the keys for separate things.
The trick is making sure you sort your data based on how you plan to use it. I’ve personally been burned by incorrectly sorting data, but it’s always been simple to troubleshoot and resolve.