Why we have to convert it to double? Maybe better idea would be to use compare_function?