sort: Use a comparer instead of returner

This resolves the FIXME of sorting ranges according to first_ip in IPv6 mode.
sort: Get rid of global comparer