(query_string)
return urllib.parse.urlencode(qs_parts)
Sort a query string using field names and urlencode it
Sort a query string using field names and urlencode it
Sort a query string using field names and urlencode it
def sort_querystring(query_string):
    """Sort a query string using field names and urlencode it"""
    # Split the query string into parts
    qs_parts = urllib.parse.parse_qsl(query_string)
    # Sort the parts (by field) and remove duplicates
    qs_parts = sorted(set(qs_parts))
    # Return sorted query string
    return urllib.parse.urlencode(qs_parts)
def sort_querystring ( query_string ) : # Split the query string into parts qs_parts = urllib . parse . parse_qsl ( query_string ) # Sort the parts (by field) and remove duplicates qs_parts = sorted ( set ( qs_parts ) ) # Return sorted query string return urllib . parse . urlencode ( qs_parts )