moving null checks for sortfn

this should work now for all the built in ones and that its in one place.