Now _sort_formats should be called explicitly. _sort_formats has been added to all the necessary places in code. Closes #8051
encode_dict functionality has been improved and moved directly into compat_urllib_parse_urlencode All occurrences of compat_urllib_parse.urlencode throughout the codebase have been replaced by compat_urllib_parse_urlencode Closes #8974