$i = 0;
while($i < 100)
{
	$data[] = mt_rand(1,10000); 
	$i++;
}

function quick_sort($data)
{
	$len = count($data);

	//debug($len);

	if($len <= 1) 
	{
		return $data;
	}

	$key = $data[0];

	$left = array();
	$right = array();

	for($i = 1; $i < $len; $i++)
	{
		if($data[$i] <= $key)
		{
			$left[] = $data[$i];
		}
		else
		{
			$right[] = $data[$i];
		}

	}
	//return;
	$left = quick_sort($left);
	$right = quick_sort($right);

	return array_merge($left, array($key), $right);
}

print_r(quick_sort($data));