@staticmethod
def _sort(x: tuple, allow_duplicates=False) ->tuple:
    """
        Sorts a tuple, optionally removing duplicates.

        Parameters
        ----------
        x:
            Tuple to be sorted.
        allow_duplicates:
            If True, duplicate entries are kept

        Returns
        -------
            A sorted tuple.
        """
    if allow_duplicates:
        return tuple(sorted(x))
    return tuple(sorted(set(x)))
