Correctly sort neighbors.