<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def normalize_url(url: 'Union[URL, str]') -> 'URL': """Normalize url to make comparisons."""

    url = URL(url)
    return url.with_query(urlencode(sorted(parse_qsl(url.query_string))))