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;
		});
	}