Move std_compare code back to compare_function