Playing around with a custom built CMS and I have an issue where I have several Postal Codes saved to the database relating to a specific store.
I am loading them within an Object array as such
Array (
[0] => PostalCodes Object (
[ID] => 0fea73e60ef4e5809e1ec4900a1f6075
[StoreID] => 7f0563d8e451d2342ca4b6a3b5402665
[PostalCode] => L2E
)
[1] => PostalCodes Object (
[ID] => 11e82b7f0e69dd3982352cf6b983ca9f
[StoreID] => 7f0563d8e451d2342ca4b6a3b5402665
[PostalCode] => L0R1S0
)
)
My question is what would be the most efficient way to sort them mixed Alphabetically & Numerically before outputting them in a for each loop?
The function is called
usort(), and you can simply usestrcmp()on the postal codes.Also, in your future postings be sure to post your data with more easily readable formatting. A lot of people will not bother to take the time to read or reformat what you originally posted.