public function asc(array $collection)
    {
        $count = count($collection);

        if ($count < 2) {
            return $collection;
        }

        $leftCollection = array();
        $rightCollection = array();

        reset($collection);

        $sortPivot = key($collection);
        $pivot = array_shift($collection);

        foreach ($collection as $key => $value) {
            if ($value < $pivot == $this->forwardSort) {
                $leftCollection[$key] = $value;
            } else {
                $rightCollection[$key] = $value;
            }
        }

        return array_merge($this->asc($leftCollection),
            array($sortPivot => $pivot),
            $this->asc($rightCollection));
    }
public function asc(array $collection)
    {
        $count = count($collection);

        if ($count < 2) {
            return $collection;
        }

        $leftCollection = array();
        $rightCollection = array();

        reset($collection);

        $sortPivot = key($collection);
        $pivot = array_shift($collection);

        foreach ($collection as $key => $value) {
            if ($value < $pivot == $this->forwardSort) {
                $leftCollection[$key] = $value;
            } else {
                $rightCollection[$key] = $value;
            }
        }

        return array_merge($this->asc($leftCollection),
            array($sortPivot => $pivot),
            $this->asc($rightCollection));
    }
public function asc ( array $ collection ) { $ count = count ( $ collection ) ; if ( $ count < 2 ) { return $ collection ; } $ leftCollection = array ( ) ; $ rightCollection = array ( ) ; reset ( $ collection ) ; $ sortPivot = key ( $ collection ) ; $ pivot = array_shift ( $ collection ) ; foreach ( $ collection as $ key => $ value ) { if ( $ value < $ pivot == $ this -> forwardSort ) { $ leftCollection [ $ key ] = $ value ; } else { $ rightCollection [ $ key ] = $ value ; } } return array_merge ( $ this -> asc ( $ leftCollection ) , array ( $ sortPivot => $ pivot ) , $ this -> asc ( $ rightCollection ) ) ; }
Sorts the given array using a quick sort algorithm.

@param  array $collection

@return array
Sorts the given array using a quick sort algorithm .