         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 """

      0

  """
  @spec max(t, (element, element -> boolean) | module(), (() -> empty_result)) ::
          element | empty_result
        when empty_result: any
  def max(enumerable, sorter \\ &>=/2, empty_fallback \\ fn -> raise Enum.EmptyError end) do
    {sorter, empty_fallback} = max_sort_fun(sorter, empty_fallback)
    aggregate(enumerable, sorter, empty_fallback)
  end

  # TODO: Deprecate me on 1.14
  defp max_sort_fun(empty_fallback, default_empty_fallback)
       when is_function(empty_fallback, 0) and is_function(default_empty_fallback, 0),
       do: {&>=/2, empty_fallback}

  defp max_sort_fun(sorter, empty_fallback)
       when is_function(sorter, 2) and is_function(empty_fallback, 0),
       do: {sorter, empty_fallback}

  defp max_sort_fun(module, empty_fallback)
       when is_atom(module) and is_function(empty_fallback, 0),
       do: {&(module.compare(&1, &2) != :lt), empty_fallback}

  @doc """
  Returns the maximal element in the `enumerable` as calculated

  """
  @spec min_by(t, (element -> any), (() -> empty_result)) :: element | empty_result
        when empty_result: any
  @spec min_by(
          t,
          (element -> any),
          (element, element -> boolean) | module(),
          (() -> empty_result)
        ) :: element | empty_result
        when empty_result: any
  def min_by(enumerable, fun, sorter \\ &<=/2, empty_fallback \\ fn -> raise Enum.EmptyError end)
      when is_function(fun, 1) do
    aggregate_by(enumerable, fun, min_sort_fun(sorter), empty_fallback)
  end

  @doc """
