nodes: 0, module; 1, function_definition; 2, function_name:_field_sort_name; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:name; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:"""Get a sort key for a field name that determines the order
          fields should be written in.
  
          Fields names are kept unchanged, unless they are instances of
          :class:`DateItemField`, in which case `year`, `month`, and `day`
          are replaced by `date0`, `date1`, and `date2`, respectively, to
          make them appear in that order.
          """; 11, call; 12, block; 13, identifier:name; 14, identifier:isinstance; 15, argument_list; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, subscript; 20, identifier:DateItemField; 21, assignment; 22, assignment; 23, assignment; 24, attribute; 25, identifier:name; 26, identifier:name; 27, call; 28, identifier:name; 29, call; 30, identifier:name; 31, call; 32, identifier:cls; 33, identifier:__dict__; 34, attribute; 35, argument_list; 36, attribute; 37, argument_list; 38, attribute; 39, argument_list; 40, identifier:re; 41, identifier:sub; 42, string; 43, string; 44, identifier:name; 45, identifier:re; 46, identifier:sub; 47, string; 48, string; 49, identifier:name; 50, identifier:re; 51, identifier:sub; 52, string; 53, string; 54, identifier:name; 55, string_content:year; 56, string_content:date0; 57, string_content:month; 58, string_content:date1; 59, string_content:day; 60, string_content:date2
code: def _field_sort_name(cls, name):
          """Get a sort key for a field name that determines the order
          fields should be written in.
  
          Fields names are kept unchanged, unless they are instances of
          :class:`DateItemField`, in which case `year`, `month`, and `day`
          are replaced by `date0`, `date1`, and `date2`, respectively, to
          make them appear in that order.
          """
          if isinstance(cls.__dict__[name], DateItemField):
              name = re.sub('year',  'date0', name)
              name = re.sub('month', 'date1', name)
              name = re.sub('day',   'date2', name)
          return name