nodes: 0, module; 1, function_definition; 2, function_name:_sort_results; 3, parameters; 4, block; 5, identifier:self; 6, identifier:results; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, comment:"""
          Order the results.
  
          :param results: The disordened results.
          :type results: array.bs4.element.Tag
          :return: The ordened results.
          :rtype: array.bs4.element.Tag
          """; 15, assignment; 16, assignment; 17, identifier:result; 18, identifier:results; 19, block; 20, assignment; 21, identifier:group; 22, identifier:groups; 23, block; 24, identifier:array; 25, identifier:parents; 26, list; 27, identifier:groups; 28, list; 29, if_statement; 30, identifier:array; 31, list; 32, expression_statement; 33, not_operator; 34, block; 35, else_clause; 36, augmented_assignment; 37, call; 38, expression_statement; 39, expression_statement; 40, expression_statement; 41, block; 42, identifier:array; 43, call; 44, attribute; 45, argument_list; 46, call; 47, call; 48, call; 49, expression_statement; 50, identifier:sorted; 51, argument_list; 52, identifier:self; 53, identifier:_in_list; 54, identifier:parents; 55, attribute; 56, attribute; 57, argument_list; 58, attribute; 59, argument_list; 60, attribute; 61, argument_list; 62, call; 63, identifier:group; 64, keyword_argument; 65, identifier:result; 66, identifier:parent; 67, identifier:parents; 68, identifier:append; 69, attribute; 70, identifier:groups; 71, identifier:append; 72, list; 73, subscript; 74, identifier:append; 75, identifier:result; 76, attribute; 77, argument_list; 78, identifier:key; 79, lambda; 80, identifier:result; 81, identifier:parent; 82, identifier:groups; 83, binary_operator:len(groups) - 1; 84, subscript; 85, identifier:append; 86, identifier:result; 87, lambda_parameters; 88, call; 89, call; 90, integer:1; 91, identifier:groups; 92, call; 93, identifier:element; 94, attribute; 95, argument_list; 96, identifier:len; 97, argument_list; 98, attribute; 99, argument_list; 100, attribute; 101, identifier:index; 102, identifier:element; 103, identifier:groups; 104, identifier:parents; 105, identifier:index; 106, attribute; 107, attribute; 108, identifier:contents; 109, identifier:result; 110, identifier:parent; 111, identifier:element; 112, identifier:parent
code: def _sort_results(self, results):
          """
          Order the results.
  
          :param results: The disordened results.
          :type results: array.bs4.element.Tag
          :return: The ordened results.
          :rtype: array.bs4.element.Tag
          """
  
          parents = []
          groups = []
          for result in results:
              if not self._in_list(parents, result.parent):
                  parents.append(result.parent)
                  groups.append([])
                  groups[len(groups) - 1].append(result)
              else:
                  groups[parents.index(result.parent)].append(result)
          array = []
          for group in groups:
              array += sorted(
                  group,
                  key=lambda element: element.parent.contents.index(element)
              )
          return array