solving the issue of sorting (issue #18)