fix incorrect cast of comparison function and signature of function