nodes: 0, module; 1, function_definition; 2, function_name:get_sorted_proposal_list; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:"""Return a list of `CodeAssistProposal`"""; 13, assignment; 14, identifier:proposal; 15, attribute; 16, block; 17, assignment; 18, identifier:scope; 19, attribute; 20, block; 21, identifier:result; 22, identifier:proposals; 23, dictionary; 24, identifier:self; 25, identifier:proposals; 26, expression_statement; 27, identifier:result; 28, list; 29, identifier:self; 30, identifier:scopepref; 31, expression_statement; 32, expression_statement; 33, expression_statement; 34, expression_statement; 35, call; 36, assignment; 37, assignment; 38, call; 39, call; 40, attribute; 41, argument_list; 42, identifier:scope_proposals; 43, call; 44, identifier:scope_proposals; 45, list_comprehension; 46, attribute; 47, argument_list; 48, attribute; 49, argument_list; 50, call; 51, identifier:append; 52, identifier:proposal; 53, attribute; 54, argument_list; 55, identifier:proposal; 56, for_in_clause; 57, if_clause; 58, identifier:scope_proposals; 59, identifier:sort; 60, keyword_argument; 61, identifier:result; 62, identifier:extend; 63, identifier:scope_proposals; 64, attribute; 65, argument_list; 66, identifier:proposals; 67, identifier:get; 68, identifier:scope; 69, list; 70, identifier:proposal; 71, identifier:scope_proposals; 72, comparison_operator:proposal.type in self.typerank; 73, identifier:key; 74, attribute; 75, identifier:proposals; 76, identifier:setdefault; 77, attribute; 78, list; 79, attribute; 80, attribute; 81, identifier:self; 82, identifier:_proposal_key; 83, identifier:proposal; 84, identifier:scope; 85, identifier:proposal; 86, identifier:type; 87, identifier:self; 88, identifier:typerank
code: def get_sorted_proposal_list(self):
          """Return a list of `CodeAssistProposal`"""
          proposals = {}
          for proposal in self.proposals:
              proposals.setdefault(proposal.scope, []).append(proposal)
          result = []
          for scope in self.scopepref:
              scope_proposals = proposals.get(scope, [])
              scope_proposals = [proposal for proposal in scope_proposals
                                 if proposal.type in self.typerank]
              scope_proposals.sort(key=self._proposal_key)
              result.extend(scope_proposals)
          return result