def is_weak_order(o):
    """Whether an object is a weak order.

    Parameters
    ----------
    o : object

    Returns
    -------
    bool
        True iff `o` is a string that represent a weak order, i.e. of the form 'a>b~c' (lover) or 'a~b>c' (hater).

    Examples
    --------
        >>> is_weak_order('a>b~c')
        True
        >>> is_weak_order('a>b~')
        False
        >>> is_weak_order(42)
        False
    """
    return isinstance(o, str) and len(o) == 5 and {o[1], o[3]} == {'>', '~'}
