Answers for "php sort by order asc"

PHP
4

quick sort php

<?php
function quick_sort($my_array)
 {
	$loe = $gt = array();
	if(count($my_array) < 2)
	{
		return $my_array;
	}
	$pivot_key = key($my_array);
	$pivot = array_shift($my_array);
	foreach($my_array as $val)
	{
		if($val <= $pivot)
		{
			$loe[] = $val;
		}elseif ($val > $pivot)
		{
			$gt[] = $val;
		}
	}
	return array_merge(quick_sort($loe),array($pivot_key=>$pivot),quick_sort($gt));
}
Posted by: Guest on July-15-2020
1

php sort hight to low

$letters=array("b","a","c");
arsort($letters); //referse sort an array ("c","a","b")
Posted by: Guest on December-05-2020

Browse Popular Code Answers by Language