/** * Returns the children of the element ordered according to their weight. * * @return array */ public function get_ordered_children() { if (!$this->children) { return []; } return sort_by_weight($this->children, function ($v) { return $v instanceof self ? $v[self::WEIGHT] ?: 0 : 0; }); }
/** * @dataProvider provide_test_sort_by_weight */ public function test_sort_by_weight($array, $expected) { $this->assertSame($expected, sort_by_weight($array, function ($v) { return $v; })); }