public static function sortByField($input, $field, $descending = false)
    {
        $returnValue = array();
		
		$sorted = array();
		foreach($input as $key => $value ){
			$sorted[$key] = $value[$field];
		}

		if($descending){
			arsort($sorted);
		}
		else{
			asort($sorted);
		}

		foreach ($sorted as $key => $value ){
			$returnValue[$key] = $input[$key];
		}

        return (array) $returnValue;
    }
public static function sortByField($input, $field, $descending = false)
    {
        $returnValue = array();
		
		$sorted = array();
		foreach($input as $key => $value ){
			$sorted[$key] = $value[$field];
		}

		if($descending){
			arsort($sorted);
		}
		else{
			asort($sorted);
		}

		foreach ($sorted as $key => $value ){
			$returnValue[$key] = $input[$key];
		}

        return (array) $returnValue;
    }
public static function sortByField ( $ input , $ field , $ descending = false ) { $ returnValue = array ( ) ; $ sorted = array ( ) ; foreach ( $ input as $ key => $ value ) { $ sorted [ $ key ] = $ value [ $ field ] ; } if ( $ descending ) { arsort ( $ sorted ) ; } else { asort ( $ sorted ) ; } foreach ( $ sorted as $ key => $ value ) { $ returnValue [ $ key ] = $ input [ $ key ] ; } return ( array ) $ returnValue ; }
Sort an associative array on a key criterion. Uses sort or asort PHP
functions to implement the sort depending on the value of the descending
parameter.

@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@param  array input The associative array to sort.
@param  string field The key criterion.
@param  boolean (optional, default = Ascending sort) descending Descending or Ascending order.
@return array An associative array.
Sort an associative array on a key criterion . Uses sort or asort PHP functions to implement the sort depending on the value of the descending parameter .