fix #4260: sort by distance doesn't work