src/Alg/Sort/Quick.php
public static function sort( &$array, $first = NULL, $last = NULL )
	{
		if( !is_array( $array ) )
			return FALSE;
		if( is_null( $first ) )
			$first = 0;
		if( is_null( $last ) )
			$last = count( $array ) - 1;
		if( $first < $last )
		{
			$middle		= $first + $last;
			$middle		= floor( ( $first + $last ) / 2 );
			$compare	= $array[$middle];
			$left		= $first;
			$right	= $last;
			while( $left <= $right )
			{
				while( $array[$left] < $compare )
					$left++;
				while( $array[$right] > $compare )
					$right--;
				if( $left <= $right )
				{
					self::swap( $array, $left, $right );
					$left++;
					$right--;
				}
			}
			self::sort( $array, $first, $right );
			self::sort( $array, $left, $last );
		}
		return $array;
	}
public static function sort( &$array, $first = NULL, $last = NULL )
	{
		if( !is_array( $array ) )
			return FALSE;
		if( is_null( $first ) )
			$first = 0;
		if( is_null( $last ) )
			$last = count( $array ) - 1;
		if( $first < $last )
		{
			$middle		= $first + $last;
			$middle		= floor( ( $first + $last ) / 2 );
			$compare	= $array[$middle];
			$left		= $first;
			$right	= $last;
			while( $left <= $right )
			{
				while( $array[$left] < $compare )
					$left++;
				while( $array[$right] > $compare )
					$right--;
				if( $left <= $right )
				{
					self::swap( $array, $left, $right );
					$left++;
					$right--;
				}
			}
			self::sort( $array, $first, $right );
			self::sort( $array, $left, $last );
		}
		return $array;
	}
public static function sort ( & $ array , $ first = NULL , $ last = NULL ) { if ( ! is_array ( $ array ) ) return FALSE ; if ( is_null ( $ first ) ) $ first = 0 ; if ( is_null ( $ last ) ) $ last = count ( $ array ) - 1 ; if ( $ first < $ last ) { $ middle = $ first + $ last ; $ middle = floor ( ( $ first + $ last ) / 2 ) ; $ compare = $ array [ $ middle ] ; $ left = $ first ; $ right = $ last ; while ( $ left <= $ right ) { while ( $ array [ $ left ] < $ compare ) $ left ++ ; while ( $ array [ $ right ] > $ compare ) $ right -- ; if ( $ left <= $ right ) { self :: swap ( $ array , $ left , $ right ) ; $ left ++ ; $ right -- ; } } self :: sort ( $ array , $ first , $ right ) ; self :: sort ( $ array , $ left , $ last ) ; } return $ array ; }
Sorts an array of numeric values with the quicksort algorithm.
@access		public
@static
@param		array		$array		Array of numeric values passed by reference
@param		int			$first		Start index
@param		int			$last		End index
@return		bool
Sorts an array of numeric values with the quicksort algorithm .