Utility/ArraySort.php
public static function multisort($array, $params) {
		static::$_cache = array();
		$isNumeric = is_numeric(implode('', array_keys($array)));
		if (is_array($params)) {
			static::_normalizeParams($params);
			$callback = function($a, $b) use($params) {
				$result = 0;
				foreach ($params as $param) {
					$valA = static::_getValue($param['field'], $a);
					$valB = static::_getValue($param['field'], $b);
					if ($valA > $valB) {
						$result = 1;
					} elseif ($valA < $valB) {
						$result = -1;
					}
					if ($result !== 0) {
						if (strtolower($param['direction']) === 'desc') {
							$result *= -1;
						}
						break;
					}
				}
				return $result;
			};
			if ($isNumeric) {
				usort($array, $callback);
			} else {
				uasort($array, $callback);
			}
		} elseif (is_string($params)) {
			if ($isNumeric) {
				(strtolower($params) === 'desc') ? rsort($array) : sort($array);
			} else {
				(strtolower($params) === 'desc') ? arsort($array) : asort($array);
			}
		}
		return $array;
	}
public static function multisort($array, $params) {
		static::$_cache = array();
		$isNumeric = is_numeric(implode('', array_keys($array)));
		if (is_array($params)) {
			static::_normalizeParams($params);
			$callback = function($a, $b) use($params) {
				$result = 0;
				foreach ($params as $param) {
					$valA = static::_getValue($param['field'], $a);
					$valB = static::_getValue($param['field'], $b);
					if ($valA > $valB) {
						$result = 1;
					} elseif ($valA < $valB) {
						$result = -1;
					}
					if ($result !== 0) {
						if (strtolower($param['direction']) === 'desc') {
							$result *= -1;
						}
						break;
					}
				}
				return $result;
			};
			if ($isNumeric) {
				usort($array, $callback);
			} else {
				uasort($array, $callback);
			}
		} elseif (is_string($params)) {
			if ($isNumeric) {
				(strtolower($params) === 'desc') ? rsort($array) : sort($array);
			} else {
				(strtolower($params) === 'desc') ? arsort($array) : asort($array);
			}
		}
		return $array;
	}
public static function multisort ( $ array , $ params ) { static :: $ _cache = array ( ) ; $ isNumeric = is_numeric ( implode ( '' , array_keys ( $ array ) ) ) ; if ( is_array ( $ params ) ) { static :: _normalizeParams ( $ params ) ; $ callback = function ( $ a , $ b ) use ( $ params ) { $ result = 0 ; foreach ( $ params as $ param ) { $ valA = static :: _getValue ( $ param [ 'field' ] , $ a ) ; $ valB = static :: _getValue ( $ param [ 'field' ] , $ b ) ; if ( $ valA > $ valB ) { $ result = 1 ; } elseif ( $ valA < $ valB ) { $ result = - 1 ; } if ( $ result !== 0 ) { if ( strtolower ( $ param [ 'direction' ] ) === 'desc' ) { $ result *= - 1 ; } break ; } } return $ result ; } ; if ( $ isNumeric ) { usort ( $ array , $ callback ) ; } else { uasort ( $ array , $ callback ) ; } } elseif ( is_string ( $ params ) ) { if ( $ isNumeric ) { ( strtolower ( $ params ) === 'desc' ) ? rsort ( $ array ) : sort ( $ array ) ; } else { ( strtolower ( $ params ) === 'desc' ) ? arsort ( $ array ) : asort ( $ array ) ; } } return $ array ; }
Sort array by multiple fields

@param array $array Array to sort
@param $params associative array key is field to sort by, value is desc or asc
you can yse Set (Hash) notation for fields
Sort array by multiple fields