code: def calls_sorted(self):
          def _z(call):
              if isinstance(call.z.value, np.ndarray):
                  return np.mean(call.z.value.flatten())
              elif isinstance(call.z.value, float) or isinstance(call.z.value, int):
                  return call.z.value
              else:
                  return -np.inf
          calls = self._calls
          zs = np.array([_z(c) for c in calls])
          sorted_inds = zs.argsort()
          return _call.make_callgroup(np.array(calls)[sorted_inds].tolist())