nodes: 0, module; 1, function_definition; 2, function_name:_compile_itemsort; 3, parameters; 4, block; 5, expression_statement; 6, function_definition; 7, function_definition; 8, function_definition; 9, function_definition; 10, function_definition; 11, comment:# priority list for map sorting (in order of checking); 12, comment:# We want Extra to match last, because it's a catch-all. On the other hand,; 13, comment:# Remove markers should match first (since invalid values will not; 14, comment:# raise an Error, instead the validator will check if other schemas match; 15, comment:# the same value).; 16, expression_statement; 17, comment:# Extra lowest priority; 18, function_definition; 19, return_statement; 20, string; 21, function_name:is_extra; 22, parameters; 23, block; 24, function_name:is_remove; 25, parameters; 26, block; 27, function_name:is_marker; 28, parameters; 29, block; 30, function_name:is_type; 31, parameters; 32, block; 33, function_name:is_callable; 34, parameters; 35, block; 36, assignment; 37, function_name:item_priority; 38, parameters; 39, block; 40, identifier:item_priority; 41, string_content:return sort function of mappings; 42, identifier:key_; 43, return_statement; 44, identifier:key_; 45, return_statement; 46, identifier:key_; 47, return_statement; 48, identifier:key_; 49, return_statement; 50, identifier:key_; 51, return_statement; 52, identifier:priority; 53, list; 54, identifier:item_; 55, expression_statement; 56, for_statement; 57, comment:# values have hightest priorities; 58, return_statement; 59, comparison_operator:key_ is Extra; 60, call; 61, call; 62, call; 63, call; 64, tuple; 65, comment:# Remove highest priority after values; 66, tuple; 67, comment:# then other Markers; 68, tuple; 69, comment:# types/classes lowest before Extra; 70, tuple; 71, comment:# callables after markers; 72, tuple; 73, assignment; 74, pattern_list; 75, identifier:priority; 76, block; 77, integer:0; 78, identifier:key_; 79, identifier:Extra; 80, identifier:isinstance; 81, argument_list; 82, identifier:isinstance; 83, argument_list; 84, attribute; 85, argument_list; 86, identifier:callable; 87, argument_list; 88, integer:1; 89, identifier:is_remove; 90, integer:2; 91, identifier:is_marker; 92, integer:4; 93, identifier:is_type; 94, integer:3; 95, identifier:is_callable; 96, integer:5; 97, identifier:is_extra; 98, identifier:key_; 99, subscript; 100, identifier:i; 101, identifier:check_; 102, if_statement; 103, identifier:key_; 104, identifier:Remove; 105, identifier:key_; 106, identifier:Marker; 107, identifier:inspect; 108, identifier:isclass; 109, identifier:key_; 110, identifier:key_; 111, identifier:item_; 112, integer:0; 113, call; 114, block; 115, identifier:check_; 116, argument_list; 117, return_statement; 118, identifier:key_; 119, identifier:i
code: def _compile_itemsort():
      '''return sort function of mappings'''
  
      def is_extra(key_):
          return key_ is Extra
  
      def is_remove(key_):
          return isinstance(key_, Remove)
  
      def is_marker(key_):
          return isinstance(key_, Marker)
  
      def is_type(key_):
          return inspect.isclass(key_)
  
      def is_callable(key_):
          return callable(key_)
  
      # priority list for map sorting (in order of checking)
      # We want Extra to match last, because it's a catch-all. On the other hand,
      # Remove markers should match first (since invalid values will not
      # raise an Error, instead the validator will check if other schemas match
      # the same value).
      priority = [(1, is_remove),  # Remove highest priority after values
                  (2, is_marker),  # then other Markers
                  (4, is_type),  # types/classes lowest before Extra
                  (3, is_callable),  # callables after markers
                  (5, is_extra)]  # Extra lowest priority
  
      def item_priority(item_):
          key_ = item_[0]
          for i, check_ in priority:
              if check_(key_):
                  return i
          # values have hightest priorities
          return 0
  
      return item_priority