How to do it. For example we have an array:
array(
0 => 'Regular 1 000',
1 => 'Regular 500',
2 => 'Regular 2 000',
3 => 'Big',
4 => 'Regular 1 000 000',
5 => 'Regular 50 000'
)
I need to place them in this order:
array(
3 => 'Big',
1 => 'Regular 500',
0 => 'Regular 1 000',
2 => 'Regular 2 000',
5 => 'Regular 50 000',
4 => 'Regular 1 000 000'
)
And I need to maintain index associations. It appears I need to use uasort. Could anyone suggest to me a function to use for the callable ( $cmp_function ) value?
This works only on the numerical part of your array, but I’m still trying to wrap my head around juggling arrays for the alphabetical sorting. Feel free to update this if anyone can add to it.You might want to try changing your formatting if possible, because this was a headache.
Gives:
EDIT: Eureka!
Note:
strcasecmp(string $a, string $b)is a case insensitive numerical way to check if in order.print_rreturns: