def header_elements(fieldname, fieldvalue):
    """Return a sorted :class:`HeaderElement` list.

    Constucted from a comma-separated header string.
    """
    if not fieldvalue:
        return []

    result = []
    for element in RE_HEADER_SPLIT.split(fieldvalue):
        if fieldname.startswith('Accept') or fieldname == 'TE':
            hv = AcceptElement.from_str(element)
        else:
            hv = HeaderElement.from_str(element)
        result.append(hv)

    return list(reversed(sorted(result)))
Return a sorted :class:`HeaderElement` list.

    Constucted from a comma-separated header string.
    
cherrypy/lib/httputil.py