Tengo la siguiente matriz:varias ordenaciones en un arsenal
Array
(
[0] => Array
(
[note] => test
[year] => 2011
[type] => football
)
[1] => Array
(
[note] => test1
[year] => 2010
[type] => basket
)
[2] => Array
(
[note] => test2
[year] => 2012
[type] => football
)
[3] => Array
(
[note] => test3
[year] => 2009
[type] => basket
)
[4] => Array
(
[note] => test4
[year] => 2010
[type] => football
)
)
Y quisiera ordenar primero que según otra matriz por tipo:
Por ejemplo: $sort = array('football','basket');
Y después por año.
¿Cómo puedo hacer eso?
Gracias.
salida deseada debe ser:
Array
(
[2] => Array
(
[note] => test2
[year] => 2012
[type] => football
)
[0] => Array
(
[note] => test
[year] => 2011
[type] => football
)
[4] => Array
(
[note] => test4
[year] => 2010
[type] => football
)
[1] => Array
(
[note] => test1
[year] => 2010
[type] => basket
)
[3] => Array
(
[note] => test3
[year] => 2009
[type] => basket
)
)
no me importa si restablecer los valores de índice.
Gracias.
Gracias amigo parece que funciona. ¿Pero cómo puedo incluir la matriz $ sortBy también? – glarkou
@salamis Edité mi respuesta para cubrir eso también. – lafor
Gracias amigo parece que funciona como se esperaba. una pregunta rápida. ¿Por qué seguimos usando '$ type, SORT_ASC' si estamos ordenando por otra matriz? – glarkou