nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, return_statement; 12, comment:"""
          Sort the list based on dependancies.
          @return: The sorted items.
          @rtype: list
          """; 13, assignment; 14, assignment; 15, identifier:item; 16, attribute; 17, block; 18, assignment; 19, attribute; 20, attribute; 21, call; 22, attribute; 23, call; 24, identifier:self; 25, identifier:unsorted; 26, expression_statement; 27, expression_statement; 28, while_statement; 29, for_statement; 30, attribute; 31, attribute; 32, identifier:self; 33, identifier:sorted; 34, identifier:self; 35, identifier:sorted; 36, identifier:list; 37, argument_list; 38, identifier:self; 39, identifier:pushed; 40, identifier:set; 41, argument_list; 42, assignment; 43, call; 44, call; 45, block; 46, identifier:p; 47, identifier:popped; 48, block; 49, identifier:self; 50, identifier:unsorted; 51, identifier:self; 52, identifier:sorted; 53, identifier:popped; 54, list; 55, attribute; 56, argument_list; 57, identifier:len; 58, argument_list; 59, try_statement; 60, expression_statement; 61, identifier:self; 62, identifier:push; 63, identifier:item; 64, attribute; 65, block; 66, except_clause; 67, call; 68, identifier:self; 69, identifier:stack; 70, expression_statement; 71, expression_statement; 72, expression_statement; 73, if_statement; 74, expression_statement; 75, identifier:StopIteration; 76, block; 77, attribute; 78, argument_list; 79, assignment; 80, assignment; 81, assignment; 82, comparison_operator:refd is None; 83, block; 84, call; 85, expression_statement; 86, continue_statement; 87, attribute; 88, identifier:append; 89, identifier:p; 90, identifier:top; 91, call; 92, identifier:ref; 93, call; 94, identifier:refd; 95, call; 96, identifier:refd; 97, None; 98, expression_statement; 99, continue_statement; 100, attribute; 101, argument_list; 102, call; 103, identifier:self; 104, identifier:sorted; 105, attribute; 106, argument_list; 107, identifier:next; 108, argument_list; 109, attribute; 110, argument_list; 111, call; 112, identifier:self; 113, identifier:push; 114, identifier:refd; 115, attribute; 116, argument_list; 117, identifier:self; 118, identifier:top; 119, subscript; 120, attribute; 121, identifier:get; 122, identifier:ref; 123, attribute; 124, argument_list; 125, identifier:popped; 126, identifier:append; 127, call; 128, identifier:top; 129, integer:1; 130, identifier:self; 131, identifier:index; 132, identifier:log; 133, identifier:debug; 134, string:'"%s" not found, skipped'; 135, call; 136, attribute; 137, argument_list; 138, identifier:Repr; 139, argument_list; 140, identifier:self; 141, identifier:pop; 142, identifier:ref
code: def sort(self):
          """
          Sort the list based on dependancies.
          @return: The sorted items.
          @rtype: list
          """
          self.sorted = list()
          self.pushed = set()
          for item in self.unsorted:
              popped = []
              self.push(item)
              while len(self.stack):
                  try:
                      top = self.top()
                      ref = next(top[1])
                      refd = self.index.get(ref)
                      if refd is None:
                          log.debug('"%s" not found, skipped', Repr(ref))
                          continue
                      self.push(refd)
                  except StopIteration:
                      popped.append(self.pop())
                      continue
              for p in popped:
                  self.sorted.append(p)
          self.unsorted = self.sorted
          return self.sorted