def sort_key(self, order=None): """ Give sort_key of infimum (if possible) else sort_key of the set. """ try: infimum = self.inf if infimum.is_comparable: return default_sort_key(infimum, order) except (NotImplementedError, ValueError): pass args = tuple([default_sort_key(a, order) for a in self._sorted_args]) return self.class_key(), (len(args), args), S.One.class_key(), S.One
def set_sort_fn(s): """ Sort by infimum if possible Otherwise sort by hash. Try to put these at the end. """ try: val = s.inf if val.is_comparable: return default_sort_key(val) else: return default_sort_key(s) except (NotImplementedError, ValueError): return default_sort_key(s)
def _triangle_key(tri, triangle_sizes): """ Returns a key for the supplied triangle. It should be the same independently of the hash randomisation. """ objects = sorted(DiagramGrid._triangle_objects(tri), key=default_sort_key) return (triangle_sizes[tri], default_sort_key(objects))