def sorted_dict(value):
# type: (Mapping) -> Any
"""
Sorts a dict's keys to avoid leaking information about the
backend's handling of unordered dicts.
"""
if isinstance(value, Mapping):
return OrderedDict(
(key, sorted_dict(value[key]))
for key in sorted(iterkeys(value))
)
elif isinstance(value, Sequence) and not isinstance(value, string_types):
return list(map(sorted_dict, value))
else:
return value
评论列表
文章目录