fix a sort bug, add assert to check main point.