Comparators in arays concept

why to pass a function specifically? we can just directly put compare in the if conditioin right?