fix sort bug

Issue #148