def canonicalize_url(url, keep_blank_values=True, keep_fragments=False, encoding=None):
 (scheme, netloc, path, params, query, fragment) = parse_url(url)
 keyvals = cgi.parse_qsl(query, keep_blank_values)
 keyvals.sort()
 query = urllib.urlencode(keyvals)
 path = safe_url_string(urllib.unquote(path))
 fragment = ('' if (not keep_fragments) else fragment)
 return urlparse.urlunparse((scheme, netloc.lower(), path, params, query, fragment))

def canonicalize_url ( url , keep_blank_values = True , keep_fragments = False , encoding = None ) : ( scheme , netloc , path , params , query , fragment ) = parse_url ( url ) keyvals = cgi . parse_qsl ( query , keep_blank_values ) keyvals . sort ( ) query = urllib . urlencode ( keyvals ) path = safe_url_string ( urllib . unquote ( path ) ) fragment = ( '' if ( not keep_fragments ) else fragment ) return urlparse . urlunparse ( ( scheme , netloc . lower ( ) , path , params , query , fragment ) )
canonicalize the given url by applying the following procedures: - sort query arguments .