array array_multisort ( array &$array1 [, mixed $array1_sort_order = SORT_ASC [, mixed $array1_sort_flags = SORT_REGULAR [, mixed $... ]]] );
array_multisort function can be used to sort several arrays at once, or a multi-dimensional array by one or more dimensions.
Associative (string) keys will be maintained, but numeric keys will be re-indexed.
Your functions are bloated. Put them on a diet. Think "skinny" and "as few lines as possible."
More coming soon…keep checking back.