Refactor zrange filter code to use comparator functions

This removes the code duplication in having to check for
inclusive/exclusive ranges for the various sorted set functions.