src/Collection.php
public function orderBy($key, $direction = 'asc')
	{
		return $this->sort(function($a, $b) use ($key, $direction)
		{
			$valueA = is_object($a) ? $a->{$key} : $a[$key];
			$valueB = is_object($b) ? $b->{$key} : $b[$key];

			if ($valueA == $valueB) return 0;

			$result = ($valueA < $valueB) ? -1 : 1;

			// If the direction is descending, reverse the order.
			return $direction === 'desc' ? -($result) : $result;
		});
	}
public function orderBy($key, $direction = 'asc')
	{
		return $this->sort(function($a, $b) use ($key, $direction)
		{
			$valueA = is_object($a) ? $a->{$key} : $a[$key];
			$valueB = is_object($b) ? $b->{$key} : $b[$key];

			if ($valueA == $valueB) return 0;

			$result = ($valueA < $valueB) ? -1 : 1;

			// If the direction is descending, reverse the order.
			return $direction === 'desc' ? -($result) : $result;
		});
	}
public function orderBy ( $ key , $ direction = 'asc' ) { return $ this -> sort ( function ( $ a , $ b ) use ( $ key , $ direction ) { $ valueA = is_object ( $ a ) ? $ a -> { $ key } : $ a [ $ key ] ; $ valueB = is_object ( $ b ) ? $ b -> { $ key } : $ b [ $ key ] ; if ( $ valueA == $ valueB ) return 0 ; $ result = ( $ valueA < $ valueB ) ? - 1 : 1 ; // If the direction is descending, reverse the order. return $ direction === 'desc' ? - ( $ result ) : $ result ; } ) ; }
Orders items by a key.

@param  string  $key
@param  string  $direction
@return \Prologue\Support\Collection
Orders items by a key .