All pastes #927453 Raw Edit

Someone

public text v1 · immutable
·published 2008-03-04 09:35 UTC
rendered paste body
function arraySortByField($sourceArray, $field, $direction )
{
	$sortArray = array();
	foreach($sourceArray as $key => $value)
	{
		$sortArray[$key] = $value[$field];
	}
	asort($sortArray);
	if($direction == 'desc')
	{
		$sortArray = array_reverse($sortArray, true);
	}
	$result = array();
	foreach($sortArray as $key => $value)
	{
		$result = $sourceArray[$key];
	}
	return $result;