         when empty_result: any
   def max_by(enumerable, fun, sorter \\ &>=/2, empty_fallback \\ fn -> raise Enum.EmptyError end)
       when is_function(fun, 1) do
-    {sorter, empty_fallback} = max_sort_fun(sorter, empty_fallback)
-    aggregate_by(enumerable, fun, sorter, empty_fallback)
+    aggregate_by(enumerable, fun, max_sort_fun(sorter), empty_fallback)
   end
 
   @doc """

    {:lists.reverse(list), acc}
  end

  @doc """
  Returns the maximal element in the `enumerable` according
  to Erlang's term ordering.

      nil

  """
  @spec max_by(t, (element -> any), (() -> empty_result)) :: element | empty_result
        when empty_result: any
  @spec max_by(
          t,
          (element -> any),
