Added support for Custom Comparators

(cherry picked from commit 20c5026d667c498a6c286561cedb37c3277dd015)
Signed-off-by: Bjorn Beskow <bb@callistaenterprise.se>