def _sorted_by_type(fields):
    """Sorts params so that strings are placed before files.

    That makes a request more readable, as generally files are bigger.
    It also provides deterministic order of fields what is easier for testing.
    """
    def key(p):
        key, val = p
        if isinstance(val, (bytes, str)):
            return (0, key)
        else:
            return (1, key)
    return sorted(fields, key=key)