nodes: 0, module; 1, function_definition; 2, function_name:get_child_type_choices; 3, parameters; 4, block; 5, identifier:self; 6, identifier:request; 7, identifier:action; 8, expression_statement; 9, comment:# Get choices from the super class to check permissions.; 10, expression_statement; 11, comment:# Update label with verbose name from plugins.; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, if_statement; 16, return_statement; 17, comment:"""
          Override choice labels with ``verbose_name`` from plugins and sort.
          """; 18, assignment; 19, assignment; 20, assignment; 21, assignment; 22, identifier:plugins; 23, block; 24, identifier:choices; 25, identifier:choices; 26, call; 27, identifier:plugins; 28, call; 29, identifier:labels; 30, dictionary; 31, identifier:sort_priorities; 32, dictionary; 33, for_statement; 34, expression_statement; 35, return_statement; 36, attribute; 37, argument_list; 38, attribute; 39, argument_list; 40, identifier:plugin; 41, identifier:plugins; 42, block; 43, assignment; 44, call; 45, call; 46, line_continuation:\; 47, identifier:get_child_type_choices; 48, identifier:request; 49, identifier:action; 50, attribute; 51, identifier:get_plugins; 52, expression_statement; 53, expression_statement; 54, expression_statement; 55, identifier:choices; 56, list_comprehension; 57, identifier:sorted; 58, argument_list; 59, identifier:super; 60, argument_list; 61, identifier:self; 62, identifier:child_model_plugin_class; 63, assignment; 64, assignment; 65, assignment; 66, tuple; 67, for_in_clause; 68, identifier:choices; 69, keyword_argument; 70, identifier:ChildModelPluginPolymorphicParentModelAdmin; 71, identifier:self; 72, identifier:pk; 73, attribute; 74, subscript; 75, call; 76, subscript; 77, call; 78, identifier:ctype; 79, subscript; 80, pattern_list; 81, identifier:choices; 82, identifier:cmp; 83, lambda; 84, attribute; 85, identifier:pk; 86, identifier:labels; 87, identifier:pk; 88, identifier:capfirst; 89, argument_list; 90, identifier:sort_priorities; 91, identifier:pk; 92, identifier:getattr; 93, argument_list; 94, identifier:labels; 95, identifier:ctype; 96, identifier:ctype; 97, identifier:_; 98, lambda_parameters; 99, call; 100, identifier:plugin; 101, identifier:content_type; 102, attribute; 103, identifier:plugin; 104, string; 105, subscript; 106, identifier:a; 107, identifier:b; 108, identifier:cmp; 109, argument_list; 110, identifier:plugin; 111, identifier:verbose_name; 112, string_content:sort_priority; 113, identifier:labels; 114, identifier:pk; 115, subscript; 116, subscript; 117, identifier:sort_priorities; 118, subscript; 119, identifier:sort_priorities; 120, subscript; 121, identifier:a; 122, integer:0; 123, identifier:b; 124, integer:0
code: def get_child_type_choices(self, request, action):
          """
          Override choice labels with ``verbose_name`` from plugins and sort.
          """
          # Get choices from the super class to check permissions.
          choices = super(ChildModelPluginPolymorphicParentModelAdmin, self) \
              .get_child_type_choices(request, action)
          # Update label with verbose name from plugins.
          plugins = self.child_model_plugin_class.get_plugins()
          labels = {}
          sort_priorities = {}
  
          if plugins:
              for plugin in plugins:
                  pk = plugin.content_type.pk
                  labels[pk] = capfirst(plugin.verbose_name)
                  sort_priorities[pk] = getattr(plugin, 'sort_priority', labels[pk])
  
              choices = [(ctype, labels[ctype]) for ctype, _ in choices]
              return sorted(choices,
                  cmp=lambda a, b: cmp(
                      sort_priorities[a[0]],
                      sort_priorities[b[0]]
                  )
              )
  
          return choices