Fixing error "AttributeError: 'dict_items' object has no attribute 'sort'" on Python 3.