def merge_by(&transformer)
      raise Erlang::ImproperListError if improper?
      return merge_by { |item| item } unless block_given?
      sorted = reject(&:empty?).sort_by do |list|
        yield(list.head)
      end
      return Erlang::Nil if sorted.empty?
      return Erlang::Cons.new(sorted.head.head, sorted.tail.cons(sorted.head.tail).merge_by(&transformer))
    end
def merge_by(&transformer)
      raise Erlang::ImproperListError if improper?
      return merge_by { |item| item } unless block_given?
      sorted = reject(&:empty?).sort_by do |list|
        yield(list.head)
      end
      return Erlang::Nil if sorted.empty?
      return Erlang::Cons.new(sorted.head.head, sorted.tail.cons(sorted.head.tail).merge_by(&transformer))
    end
Merge all the nested lists into a single list, using sort keys generated
 by mapping the items in the nested lists through the given block to determine the
 order which items should be shifted out of the nested lists and into the output
 list. Whichever nested list's `#head` has the "lowest" sort key (according to
 their natural order) will be the first in the merged `List`.

 @example
   list_1 = Erlang::List[1, -3, -5]
   list_2 = Erlang::List[-2, 4, 6]
   Erlang::List[list_1, list_2].merge_by { |x| x.abs }
   # => Erlang::List[1, -2, -3, 4, -5, 6]

 @return [List]
 @yield [item] Once for each item in either list.
 @yieldreturn [Object] A sort key for the element.