Fix sorting. close #144

See #143 for description.
Merge pull request #145 from vlad-ghita/patch-2

Fix sorting. close #144