nodes: 0, module; 1, function_definition; 2, function_name:items_sort; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:items; 7, expression_statement; 8, class_definition; 9, function_definition; 10, return_statement; 11, comment:"""Sort list items, taking into account parent items.
  
          Args:
              items (list[gkeepapi.node.ListItem]): Items to sort.
          Returns:
              list[gkeepapi.node.ListItem]: Sorted items.
          """; 12, identifier:t; 13, argument_list; 14, block; 15, function_name:key_func; 16, parameters; 17, block; 18, call; 19, identifier:tuple; 20, expression_statement; 21, function_definition; 22, function_definition; 23, function_definition; 24, function_definition; 25, function_definition; 26, function_definition; 27, function_definition; 28, identifier:x; 29, if_statement; 30, return_statement; 31, identifier:sorted; 32, argument_list; 33, comment:"""Tuple with element-based sorting"""; 34, function_name:__cmp__; 35, parameters; 36, block; 37, function_name:__lt__; 38, parameters; 39, block; 40, function_name:__gt_; 41, parameters; 42, block; 43, function_name:__le__; 44, parameters; 45, block; 46, function_name:__ge_; 47, parameters; 48, block; 49, function_name:__eq__; 50, parameters; 51, block; 52, function_name:__ne__; 53, parameters; 54, block; 55, attribute; 56, block; 57, call; 58, identifier:items; 59, keyword_argument; 60, keyword_argument; 61, identifier:self; 62, identifier:other; 63, for_statement; 64, return_statement; 65, identifier:self; 66, identifier:other; 67, return_statement; 68, identifier:self; 69, identifier:other; 70, return_statement; 71, identifier:self; 72, identifier:other; 73, return_statement; 74, identifier:self; 75, identifier:other; 76, return_statement; 77, identifier:self; 78, identifier:other; 79, return_statement; 80, identifier:self; 81, identifier:other; 82, return_statement; 83, identifier:x; 84, identifier:indented; 85, return_statement; 86, identifier:t; 87, argument_list; 88, identifier:key; 89, identifier:key_func; 90, identifier:reverse; 91, True; 92, pattern_list; 93, call; 94, block; 95, integer:0; 96, comparison_operator:self.__cmp__(other) < 0; 97, comparison_operator:self.__cmp__(other) > 0; 98, comparison_operator:self.__cmp__(other) <= 0; 99, comparison_operator:self.__cmp__(other) >= 0; 100, comparison_operator:self.__cmp__(other) == 0; 101, comparison_operator:self.__cmp__(other) != 0; 102, call; 103, tuple; 104, identifier:a; 105, identifier:b; 106, attribute; 107, argument_list; 108, if_statement; 109, call; 110, integer:0; 111, call; 112, integer:0; 113, call; 114, integer:0; 115, call; 116, integer:0; 117, call; 118, integer:0; 119, call; 120, integer:0; 121, identifier:t; 122, argument_list; 123, call; 124, attribute; 125, identifier:zip_longest; 126, identifier:self; 127, identifier:other; 128, comparison_operator:a != b; 129, block; 130, attribute; 131, argument_list; 132, attribute; 133, argument_list; 134, attribute; 135, argument_list; 136, attribute; 137, argument_list; 138, attribute; 139, argument_list; 140, attribute; 141, argument_list; 142, tuple; 143, identifier:int; 144, argument_list; 145, identifier:six; 146, identifier:moves; 147, identifier:a; 148, identifier:b; 149, if_statement; 150, if_statement; 151, return_statement; 152, identifier:self; 153, identifier:__cmp__; 154, identifier:other; 155, identifier:self; 156, identifier:__cmp__; 157, identifier:other; 158, identifier:self; 159, identifier:__cmp__; 160, identifier:other; 161, identifier:self; 162, identifier:__cmp__; 163, identifier:other; 164, identifier:self; 165, identifier:__cmp__; 166, identifier:other; 167, identifier:self; 168, identifier:__cmp__; 169, identifier:other; 170, call; 171, call; 172, attribute; 173, comparison_operator:a is None; 174, block; 175, comparison_operator:b is None; 176, block; 177, binary_operator:a - b; 178, identifier:int; 179, argument_list; 180, identifier:int; 181, argument_list; 182, identifier:x; 183, identifier:sort; 184, identifier:a; 185, None; 186, return_statement; 187, identifier:b; 188, None; 189, return_statement; 190, identifier:a; 191, identifier:b; 192, attribute; 193, attribute; 194, integer:1; 195, unary_operator; 196, attribute; 197, identifier:sort; 198, identifier:x; 199, identifier:sort; 200, integer:1; 201, identifier:x; 202, identifier:parent_item
code: def items_sort(cls, items):
          """Sort list items, taking into account parent items.
  
          Args:
              items (list[gkeepapi.node.ListItem]): Items to sort.
          Returns:
              list[gkeepapi.node.ListItem]: Sorted items.
          """
          class t(tuple):
              """Tuple with element-based sorting"""
              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)