nodes: 0, module; 1, function_definition; 2, function_name:preferred_ordinal; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:attr_name; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""
          Returns an ordering value for a particular attribute key.
  
          Unrecognized attributes and OIDs will be sorted lexically at the end.
  
          :return:
              An orderable value.
  
          """; 12, assignment; 13, comparison_operator:attr_name in cls.preferred_order; 14, block; 15, else_clause; 16, tuple; 17, identifier:attr_name; 18, call; 19, identifier:attr_name; 20, attribute; 21, expression_statement; 22, block; 23, identifier:ordinal; 24, identifier:attr_name; 25, attribute; 26, argument_list; 27, identifier:cls; 28, identifier:preferred_order; 29, assignment; 30, expression_statement; 31, identifier:cls; 32, identifier:map; 33, identifier:attr_name; 34, identifier:ordinal; 35, call; 36, assignment; 37, attribute; 38, argument_list; 39, identifier:ordinal; 40, call; 41, attribute; 42, identifier:index; 43, identifier:attr_name; 44, identifier:len; 45, argument_list; 46, identifier:cls; 47, identifier:preferred_order; 48, attribute; 49, identifier:cls; 50, identifier:preferred_order
code: def preferred_ordinal(cls, attr_name):
          """
          Returns an ordering value for a particular attribute key.
  
          Unrecognized attributes and OIDs will be sorted lexically at the end.
  
          :return:
              An orderable value.
  
          """
  
          attr_name = cls.map(attr_name)
          if attr_name in cls.preferred_order:
              ordinal = cls.preferred_order.index(attr_name)
          else:
              ordinal = len(cls.preferred_order)
  
          return (ordinal, attr_name)