Implemented Hash::sortBy
Some refactoring