nodes: 0, module; 1, function_definition; 2, function_name:sortby; 3, parameters; 4, block; 5, identifier:self; 6, identifier:ntd; 7, expression_statement; 8, if_statement; 9, comment:"""Return function for sorting."""; 10, comparison_operator:'reldepth' in self.grprobj.gosubdag.prt_attr['flds']; 11, block; 12, else_clause; 13, string; 14, subscript; 15, return_statement; 16, block; 17, string_content:reldepth; 18, attribute; 19, string; 20, list; 21, return_statement; 22, attribute; 23, identifier:prt_attr; 24, string_content:flds; 25, attribute; 26, binary_operator:-1*ntd.dcnt; 27, attribute; 28, list; 29, attribute; 30, identifier:gosubdag; 31, identifier:ntd; 32, identifier:NS; 33, unary_operator; 34, attribute; 35, identifier:ntd; 36, identifier:reldepth; 37, attribute; 38, binary_operator:-1*ntd.dcnt; 39, attribute; 40, identifier:self; 41, identifier:grprobj; 42, integer:1; 43, identifier:ntd; 44, identifier:dcnt; 45, identifier:ntd; 46, identifier:NS; 47, unary_operator; 48, attribute; 49, identifier:ntd; 50, identifier:depth; 51, integer:1; 52, identifier:ntd; 53, identifier:dcnt
code: def sortby(self, ntd):
          """Return function for sorting."""
          if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']:
              return [ntd.NS, -1*ntd.dcnt, ntd.reldepth]
          else:
              return [ntd.NS, -1*ntd.dcnt, ntd.depth]