public function sort(array $ids, array $list)
    {
        $data = array();
        foreach ($ids as $key) {

            if (!isset($list[$key])) {
                return array();
            }

            $data[$key] = $list[$key]['sort'];
            foreach (array_keys($list[$key]['requires']) as $dependency) {
                if (!isset($data[$dependency])) {
                    $data[$dependency] = 0;
                }
            }
        }

        arsort($data);
        return array_keys($data);
    }
public function sort(array $ids, array $list)
    {
        $data = array();
        foreach ($ids as $key) {

            if (!isset($list[$key])) {
                return array();
            }

            $data[$key] = $list[$key]['sort'];
            foreach (array_keys($list[$key]['requires']) as $dependency) {
                if (!isset($data[$dependency])) {
                    $data[$dependency] = 0;
                }
            }
        }

        arsort($data);
        return array_keys($data);
    }
public function sort ( array $ ids , array $ list ) { $ data = array ( ) ; foreach ( $ ids as $ key ) { if ( ! isset ( $ list [ $ key ] ) ) { return array ( ) ; } $ data [ $ key ] = $ list [ $ key ] [ 'sort' ] ; foreach ( array_keys ( $ list [ $ key ] [ 'requires' ] ) as $ dependency ) { if ( ! isset ( $ data [ $ dependency ] ) ) { $ data [ $ dependency ] = 0 ; } } } arsort ( $ data ) ; return array_keys ( $ data ) ; }
Sort a list of IDs according to their dependencies
Dependent items always go last
@param array $ids
@param array $list
@return array
Sort a list of IDs according to their dependencies Dependent items always go last