I can't get this. Why doesn' this work?
$list = array(array('id' => 123), array('id' => 10), array('id' => 1000));
$this->OrderListById($list);
return $list;
public function OrderListById($list){
usort($list, function($a, $b) {return $a['id'] - $b['id'];});
}
This returns
array(
(int) 0 => array(
'id' => (int) 123
),
(int) 1 => array(
'id' => (int) 10
),
(int) 2 => array(
'id' => (int) 1000
)
)
And i was hoping something like more ordered :D
array(
(int) 0 => array(
'id' => (int) 10
),
(int) 1 => array(
'id' => (int) 123
),
(int) 2 => array(
'id' => (int) 1000
)
)