Feature/fix sorting

Fix the sorting issue.