0

I've that proceed this array in PHP

array(
    "id" => 1,
    "name" => "Carlos"
    "other" => array("key" => "Hello")
),
array(
    "id" => 3,
    "name" => "Carlos" 
    "other" => array("key" => "Hello")
),
array(
    "id" => 2,
    "name" => "Carlos"
    "other" => array("key" => "Hello")
)

and I need to order by "id". I've try it using usort and many multidimensional solutions but doesn't work for me.

I used that:

$price = array();
foreach ($inventory as $key => $row)
{
    $price[$key] = $row['price'];
}
array_multisort($price, SORT_DESC, $inventory);

But doesn't work because my array has many dimentions.

$departamento = $this->Departamentos->get($id, [
        'contain' => [
            'Asignaturas.Mallas',
            'Asignaturas.Secciones.Perfiles',
            'Asignaturas.Secciones.Mallas.Carreras',
            'Unidades'
        ]
    ]);

That is my query in Cakephp. I need to order by Secciones.id

cnavarreteliz
  • 139
  • 1
  • 3
  • 9

1 Answers1

0

I used Hash::sort http://book.cakephp.org/3.0/en/core-libraries/hash.html

And works fine for me ;)

cnavarreteliz
  • 139
  • 1
  • 3
  • 9