nodes: 0, module; 1, function_definition; 2, function_name:sort_items; 3, parameters; 4, block; 5, identifier:self; 6, identifier:items; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, function_definition; 11, function_definition; 12, function_definition; 13, function_definition; 14, function_definition; 15, if_statement; 16, identifier:args; 17, False; 18, comment:"""
      Sort the `self`'s contents, as contained in the list `items` as
      specified in `self`'s meta-data.
      """; 19, comparison_operator:self.settings['sort'].lower() == 'src'; 20, block; 21, function_name:alpha; 22, parameters; 23, block; 24, function_name:permission; 25, parameters; 26, block; 27, function_name:permission_alpha; 28, parameters; 29, block; 30, function_name:itype; 31, parameters; 32, block; 33, function_name:itype_alpha; 34, parameters; 35, block; 36, comparison_operator:self.settings['sort'].lower() == 'alpha'; 37, block; 38, elif_clause; 39, elif_clause; 40, elif_clause; 41, elif_clause; 42, call; 43, string; 44, return_statement; 45, identifier:i; 46, return_statement; 47, identifier:i; 48, if_statement; 49, expression_statement; 50, if_statement; 51, if_statement; 52, if_statement; 53, return_statement; 54, identifier:i; 55, return_statement; 56, identifier:i; 57, if_statement; 58, identifier:i; 59, return_statement; 60, call; 61, string; 62, expression_statement; 63, comparison_operator:self.settings['sort'].lower() == 'permission'; 64, block; 65, comparison_operator:self.settings['sort'].lower() == 'permission-alpha'; 66, block; 67, comparison_operator:self.settings['sort'].lower() == 'type'; 68, block; 69, comparison_operator:self.settings['sort'].lower() == 'type-alpha'; 70, block; 71, attribute; 72, argument_list; 73, string_content:src; 74, attribute; 75, identifier:args; 76, block; 77, assignment; 78, comparison_operator:perm == 'public'; 79, block; 80, comparison_operator:perm == 'protected'; 81, block; 82, comparison_operator:perm == 'private'; 83, block; 84, string; 85, binary_operator:permission(i) + '-' + i.name; 86, comparison_operator:i.obj == 'variable'; 87, block; 88, elif_clause; 89, else_clause; 90, binary_operator:itype(i) + '-' + i.name; 91, attribute; 92, argument_list; 93, string_content:alpha; 94, call; 95, call; 96, string; 97, expression_statement; 98, call; 99, string; 100, expression_statement; 101, call; 102, string; 103, expression_statement; 104, call; 105, string; 106, expression_statement; 107, subscript; 108, identifier:lower; 109, identifier:i; 110, identifier:name; 111, if_statement; 112, if_statement; 113, if_statement; 114, if_statement; 115, identifier:perm; 116, call; 117, identifier:perm; 118, string; 119, return_statement; 120, identifier:perm; 121, string; 122, return_statement; 123, identifier:perm; 124, string; 125, return_statement; 126, string_content:a; 127, binary_operator:permission(i) + '-'; 128, attribute; 129, attribute; 130, string; 131, expression_statement; 132, if_statement; 133, if_statement; 134, if_statement; 135, if_statement; 136, return_statement; 137, comparison_operator:i.obj == 'proc'; 138, block; 139, block; 140, binary_operator:itype(i) + '-'; 141, attribute; 142, subscript; 143, identifier:lower; 144, attribute; 145, argument_list; 146, attribute; 147, argument_list; 148, string_content:permission; 149, call; 150, attribute; 151, argument_list; 152, string_content:permission-alpha; 153, call; 154, attribute; 155, argument_list; 156, string_content:type; 157, call; 158, attribute; 159, argument_list; 160, string_content:type-alpha; 161, call; 162, attribute; 163, string; 164, comparison_operator:i.intent == 'in'; 165, block; 166, comparison_operator:i.intent == 'inout'; 167, block; 168, comparison_operator:i.intent == 'out'; 169, block; 170, comparison_operator:i.intent == ''; 171, block; 172, identifier:getattr; 173, argument_list; 174, string_content:public; 175, string; 176, string_content:protected; 177, string; 178, string_content:private; 179, string; 180, call; 181, string; 182, identifier:i; 183, identifier:name; 184, identifier:i; 185, identifier:obj; 186, string_content:variable; 187, assignment; 188, comparison_operator:retstr == 'class'; 189, block; 190, attribute; 191, block; 192, attribute; 193, block; 194, attribute; 195, block; 196, identifier:retstr; 197, attribute; 198, string; 199, if_statement; 200, return_statement; 201, call; 202, string; 203, identifier:i; 204, identifier:name; 205, attribute; 206, string; 207, identifier:items; 208, identifier:sort; 209, keyword_argument; 210, subscript; 211, identifier:lower; 212, attribute; 213, argument_list; 214, subscript; 215, identifier:lower; 216, attribute; 217, argument_list; 218, subscript; 219, identifier:lower; 220, attribute; 221, argument_list; 222, subscript; 223, identifier:lower; 224, attribute; 225, argument_list; 226, identifier:self; 227, identifier:settings; 228, string_content:sort; 229, attribute; 230, string; 231, return_statement; 232, attribute; 233, string; 234, return_statement; 235, attribute; 236, string; 237, return_statement; 238, attribute; 239, string; 240, return_statement; 241, identifier:i; 242, string; 243, string; 244, string_content:b; 245, string_content:c; 246, string_content:d; 247, identifier:permission; 248, argument_list; 249, string_content:-; 250, identifier:retstr; 251, attribute; 252, identifier:retstr; 253, string; 254, expression_statement; 255, identifier:i; 256, identifier:kind; 257, expression_statement; 258, identifier:i; 259, identifier:strlen; 260, expression_statement; 261, identifier:i; 262, identifier:proto; 263, expression_statement; 264, identifier:i; 265, identifier:obj; 266, string_content:proc; 267, comparison_operator:i.proctype != 'Function'; 268, block; 269, else_clause; 270, attribute; 271, identifier:itype; 272, argument_list; 273, string_content:-; 274, identifier:self; 275, identifier:settings; 276, string_content:sort; 277, identifier:key; 278, identifier:alpha; 279, attribute; 280, string; 281, identifier:items; 282, identifier:sort; 283, keyword_argument; 284, attribute; 285, string; 286, identifier:items; 287, identifier:sort; 288, keyword_argument; 289, attribute; 290, string; 291, identifier:items; 292, identifier:sort; 293, keyword_argument; 294, attribute; 295, string; 296, identifier:items; 297, identifier:sort; 298, keyword_argument; 299, identifier:i; 300, identifier:intent; 301, string_content:in; 302, string; 303, identifier:i; 304, identifier:intent; 305, string_content:inout; 306, string; 307, identifier:i; 308, identifier:intent; 309, string_content:out; 310, string; 311, identifier:i; 312, identifier:intent; 313, string; 314, string_content:permission; 315, identifier:i; 316, identifier:i; 317, identifier:vartype; 318, string_content:class; 319, assignment; 320, assignment; 321, assignment; 322, assignment; 323, attribute; 324, string; 325, return_statement; 326, block; 327, identifier:i; 328, identifier:obj; 329, identifier:i; 330, identifier:self; 331, identifier:settings; 332, string_content:sort; 333, identifier:key; 334, identifier:permission; 335, identifier:self; 336, identifier:settings; 337, string_content:sort; 338, identifier:key; 339, identifier:permission_alpha; 340, identifier:self; 341, identifier:settings; 342, string_content:sort; 343, identifier:key; 344, identifier:itype; 345, identifier:self; 346, identifier:settings; 347, string_content:sort; 348, identifier:key; 349, identifier:itype_alpha; 350, string_content:b; 351, string_content:c; 352, string_content:d; 353, string_content:e; 354, identifier:retstr; 355, string; 356, identifier:retstr; 357, binary_operator:retstr + '-' + str(i.kind); 358, identifier:retstr; 359, binary_operator:retstr + '-' + str(i.strlen); 360, identifier:retstr; 361, binary_operator:retstr + '-' + i.proto[0]; 362, identifier:i; 363, identifier:proctype; 364, string_content:Function; 365, call; 366, return_statement; 367, string_content:type; 368, binary_operator:retstr + '-'; 369, call; 370, binary_operator:retstr + '-'; 371, call; 372, binary_operator:retstr + '-'; 373, subscript; 374, attribute; 375, argument_list; 376, binary_operator:i.proctype.lower() + '-' + itype(i.retvar); 377, identifier:retstr; 378, string; 379, identifier:str; 380, argument_list; 381, identifier:retstr; 382, string; 383, identifier:str; 384, argument_list; 385, identifier:retstr; 386, string; 387, attribute; 388, integer:0; 389, attribute; 390, identifier:lower; 391, binary_operator:i.proctype.lower() + '-'; 392, call; 393, string_content:-; 394, attribute; 395, string_content:-; 396, attribute; 397, string_content:-; 398, identifier:i; 399, identifier:proto; 400, identifier:i; 401, identifier:proctype; 402, call; 403, string; 404, identifier:itype; 405, argument_list; 406, identifier:i; 407, identifier:kind; 408, identifier:i; 409, identifier:strlen; 410, attribute; 411, argument_list; 412, string_content:-; 413, attribute; 414, attribute; 415, identifier:lower; 416, identifier:i; 417, identifier:retvar; 418, identifier:i; 419, identifier:proctype
code: def sort_items(self,items,args=False):
      """
      Sort the `self`'s contents, as contained in the list `items` as
      specified in `self`'s meta-data.
      """
      if self.settings['sort'].lower() == 'src': return
      def alpha(i):
          return i.name
      def permission(i):
          if args:
              if i.intent == 'in': return 'b'
              if i.intent == 'inout': return 'c'
              if i.intent == 'out': return 'd'
              if i.intent == '': return 'e'
          perm = getattr(i, 'permission', '')
          if perm == 'public': return 'b'
          if perm == 'protected': return 'c'
          if perm == 'private': return 'd'
          return 'a'
      def permission_alpha(i):
          return permission(i) + '-' + i.name
      def itype(i):
          if i.obj == 'variable':
              retstr = i.vartype
              if retstr == 'class': retstr = 'type'
              if i.kind: retstr = retstr + '-' + str(i.kind)
              if i.strlen: retstr = retstr + '-' + str(i.strlen)
              if i.proto:
                  retstr = retstr + '-' + i.proto[0]
              return retstr
          elif i.obj == 'proc':
              if i.proctype != 'Function':
                  return i.proctype.lower()
              else:
                  return i.proctype.lower() + '-' + itype(i.retvar)
          else:
              return i.obj
      def itype_alpha(i):
          return itype(i) + '-' + i.name
  
      if self.settings['sort'].lower() == 'alpha':
          items.sort(key=alpha)
      elif self.settings['sort'].lower() == 'permission':
          items.sort(key=permission)
      elif self.settings['sort'].lower() == 'permission-alpha':
          items.sort(key=permission_alpha)
      elif self.settings['sort'].lower() == 'type':
          items.sort(key=itype)
      elif self.settings['sort'].lower() == 'type-alpha':
          items.sort(key=itype_alpha)