nodes: 0, module; 1, function_definition; 2, function_name:resort; 3, parameters; 4, block; 5, identifier:self; 6, identifier:attributeID; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, if_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, identifier:isAscending; 16, None; 17, comment:"""Sort by one of my specified columns, identified by attributeID
          """; 18, comparison_operator:isAscending is None; 19, block; 20, assignment; 21, comparison_operator:newSortColumn.sortAttribute() is None; 22, block; 23, comparison_operator:self.currentSortColumn == newSortColumn; 24, comment:# if this query is to be re-sorted on the same column, but in the; 25, comment:# opposite direction to our last query, then use the first item in; 26, comment:# the result set as the marker; 27, block; 28, else_clause; 29, assignment; 30, call; 31, identifier:isAscending; 32, None; 33, expression_statement; 34, identifier:newSortColumn; 35, subscript; 36, call; 37, None; 38, raise_statement; 39, attribute; 40, identifier:newSortColumn; 41, if_statement; 42, block; 43, attribute; 44, identifier:isAscending; 45, attribute; 46, argument_list; 47, assignment; 48, attribute; 49, identifier:attributeID; 50, attribute; 51, argument_list; 52, call; 53, identifier:self; 54, identifier:currentSortColumn; 55, comparison_operator:self.isAscending == isAscending; 56, block; 57, else_clause; 58, expression_statement; 59, expression_statement; 60, identifier:self; 61, identifier:isAscending; 62, identifier:self; 63, identifier:_updateResults; 64, call; 65, True; 66, identifier:isAscending; 67, attribute; 68, identifier:self; 69, identifier:columns; 70, identifier:newSortColumn; 71, identifier:sortAttribute; 72, identifier:Unsortable; 73, argument_list; 74, attribute; 75, identifier:isAscending; 76, expression_statement; 77, comment:# otherwise use the last; 78, block; 79, assignment; 80, assignment; 81, attribute; 82, argument_list; 83, identifier:self; 84, identifier:defaultSortAscending; 85, binary_operator:'column %r has no sort attribute' % (attributeID,); 86, identifier:self; 87, identifier:isAscending; 88, assignment; 89, expression_statement; 90, identifier:offset; 91, integer:0; 92, attribute; 93, identifier:newSortColumn; 94, identifier:self; 95, identifier:_sortAttributeValue; 96, identifier:offset; 97, string; 98, tuple; 99, identifier:offset; 100, integer:0; 101, assignment; 102, identifier:self; 103, identifier:currentSortColumn; 104, string_content:column %r has no sort attribute; 105, identifier:attributeID; 106, identifier:offset; 107, unary_operator; 108, integer:1
code: def resort(self, attributeID, isAscending=None):
          """Sort by one of my specified columns, identified by attributeID
          """
          if isAscending is None:
              isAscending = self.defaultSortAscending
  
          newSortColumn = self.columns[attributeID]
          if newSortColumn.sortAttribute() is None:
              raise Unsortable('column %r has no sort attribute' % (attributeID,))
          if self.currentSortColumn == newSortColumn:
              # if this query is to be re-sorted on the same column, but in the
              # opposite direction to our last query, then use the first item in
              # the result set as the marker
              if self.isAscending == isAscending:
                  offset = 0
              else:
                  # otherwise use the last
                  offset = -1
          else:
              offset = 0
              self.currentSortColumn = newSortColumn
          self.isAscending = isAscending
          self._updateResults(self._sortAttributeValue(offset), True)