code: def items_sort(cls, items):
          class t(tuple):
              def __cmp__(self, other):
                  for a, b in six.moves.zip_longest(self, other):
                      if a != b:
                          if a is None:
                              return 1
                          if b is None:
                              return -1
                          return a - b
                  return 0
              def __lt__(self, other):
                  return self.__cmp__(other) < 0
              def __gt_(self, other):
                  return self.__cmp__(other) > 0
              def __le__(self, other):
                  return self.__cmp__(other) <= 0
              def __ge_(self, other):
                  return self.__cmp__(other) >= 0
              def __eq__(self, other):
                  return self.__cmp__(other) == 0
              def __ne__(self, other):
                  return self.__cmp__(other) != 0
          def key_func(x):
              if x.indented:
                  return t((int(x.parent_item.sort), int(x.sort)))
              return t((int(x.sort), ))
          return sorted(items, key=key_func, reverse=True)