Updated the compareBy method to take a class argument to help the Xtend type system infer the correct type.