fixes sort and many others bugs
Merge pull request #23 from yamnich/sort-fixes

Some fixes