Discovered a new issue by adding a new test. #27
Improved sorting by a key #27