code: def sorted(self, attrname, reverse=False):
          attrs = []
          for i, pseudo in self:
              try:
                  a = getattr(pseudo, attrname)
              except AttributeError:
                  a = np.inf
              attrs.append((i, a))
          return self.__class__([self[a[0]] for a in sorted(attrs, key=lambda t: t[1], reverse=reverse)])