fix sort order so that nulls are always last