Spice up merge with a custom comparator.

Uses some experimental perl goodness. lexical
subs allow clean-looking recursion while still
closing over the comparator.