nodes: 0, module; 1, function_definition; 2, function_name:sortByColumn; 3, parameters; 4, block; 5, identifier:self; 6, identifier:index; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, comment:"""Implement a column sort."""; 14, comparison_operator:self.sort_old == [None]; 15, block; 16, assignment; 17, call; 18, not_operator; 19, block; 20, assignment; 21, attribute; 22, list; 23, expression_statement; 24, identifier:sort_order; 25, call; 26, attribute; 27, argument_list; 28, call; 29, if_statement; 30, return_statement; 31, attribute; 32, list; 33, identifier:self; 34, identifier:sort_old; 35, None; 36, call; 37, attribute; 38, argument_list; 39, attribute; 40, identifier:emit; 41, attribute; 42, argument_list; 43, comparison_operator:len(self.sort_old) != 2; 44, block; 45, else_clause; 46, identifier:self; 47, identifier:sort_old; 48, identifier:index; 49, call; 50, attribute; 51, argument_list; 52, attribute; 53, identifier:sortIndicatorOrder; 54, identifier:self; 55, identifier:sig_sort_by_column; 56, call; 57, identifier:sort; 58, identifier:index; 59, identifier:sort_order; 60, call; 61, integer:2; 62, expression_statement; 63, block; 64, attribute; 65, argument_list; 66, attribute; 67, identifier:setSortIndicatorShown; 68, True; 69, identifier:self; 70, identifier:header_class; 71, attribute; 72, argument_list; 73, identifier:len; 74, argument_list; 75, call; 76, expression_statement; 77, attribute; 78, identifier:sortIndicatorOrder; 79, identifier:self; 80, identifier:header_class; 81, identifier:self; 82, identifier:model; 83, attribute; 84, attribute; 85, argument_list; 86, call; 87, identifier:self; 88, identifier:header_class; 89, identifier:self; 90, identifier:sort_old; 91, attribute; 92, identifier:setSortIndicatorShown; 93, False; 94, attribute; 95, argument_list; 96, identifier:self; 97, identifier:header_class; 98, attribute; 99, identifier:setSortIndicator; 100, subscript; 101, subscript; 102, identifier:self; 103, identifier:header_class; 104, attribute; 105, integer:0; 106, attribute; 107, integer:1; 108, identifier:self; 109, identifier:sort_old; 110, identifier:self; 111, identifier:sort_old
code: def sortByColumn(self, index):
          """Implement a column sort."""
          if self.sort_old == [None]:
              self.header_class.setSortIndicatorShown(True)
          sort_order = self.header_class.sortIndicatorOrder()
          self.sig_sort_by_column.emit()
          if not self.model().sort(index, sort_order):
              if len(self.sort_old) != 2:
                  self.header_class.setSortIndicatorShown(False)
              else:
                  self.header_class.setSortIndicator(self.sort_old[0],
                                                     self.sort_old[1])
              return
          self.sort_old = [index, self.header_class.sortIndicatorOrder()]