¿Es natural ordenar una matriz asociativa?
Dada una matriz de matrices, ¿cómo ordenaría naturalmente las matrices internas en función de sus valores?
Matriz de ejemplo:
array (size=2)
0 =>
array (size=1)
'manager' => string 'Manager 1' (length=9)
1 =>
array (size=1)
'manager' => string 'Manager 3' (length=9)
Otro ejemplo de matriz:
array (size=2)
0 =>
array (size=1)
'month' => string 'June' (length=4)
1 =>
array (size=1)
'month' => string 'January' (length=7)
Mi primera idea fue simplementenatsort()
ellos, pero eso espera una matriz normal. La siguiente idea fue usararray_multisort($array, SORT_NATURAL);
, pero eso no funcionó debido a las matrices asociativas.
Entonces, ¿cómo podría ordenar las matrices internas al usar la ordenación natural? Además, mantener las claves de la matriz no importa en este caso.
EDITAR:
La salida esperada de la matriz 1 sería la misma (ya que el Administrador 1 y el Administrador 3 ya están en orden):
array (size=2)
0 =>
array (size=1)
'manager' => string 'Manager 1' (length=9)
1 =>
array (size=1)
'manager' => string 'Manager 3' (length=9)
La salida esperada de la matriz dos colocaría enero antes que junio (el orden 'natural'):
// 0 and 1 keys can switch or stay the same, doesn't matter
array (size=2)
0 =>
array (size=1)
'month' => string 'January' (length=4)
1 =>
array (size=1)
'month' => string 'June' (length=7)