@staticmethod
def _diff_filter(diff):
    """
        Ipset seems to add entries in a non-deterministic order when doing
        atomic replace. This will cause the differ to output changes even
        when there are none. To fix this, ensure the entries for each ipset
        is sorted before being diffed.
        """
    entries = []
    for i in diff:
        if i.startswith('add '):
            entries.append(i)
            continue
        for entry in sorted(entries):
            yield entry
        entries = []
        yield i
    for entry in sorted(entries):
        yield entry
