Fixes code that could produce KeyError in sorting methods
Merge pull request #125 from fitoria/keyerrorissue

Fixes code that could produce KeyError in sorting methods