lithium\tests\integration\test\FilterTest::_perm PHP Method

_perm() protected method

protected _perm ( $arr, $nth = null )
    protected function _perm($arr, $nth = null)
    {
        if ($nth === null) {
            return $this->_perms($arr);
        }
        $result = array();
        $length = count($arr);
        while ($length--) {
            $f = $this->_factorial($length);
            $p = floor($nth / $f);
            $result[] = $arr[$p];
            $this->_arrayDeleteByKey($arr, $p);
            $nth -= $p * $f;
        }
        $result = array_merge($result, $arr);
        return $result;
    }