nodes: 0, module; 1, function_definition; 2, function_name:es_field_sort; 3, parameters; 4, block; 5, identifier:fld_name; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:""" Used with lambda to sort fields """; 11, assignment; 12, comparison_operator:"_" not in parts[-1]; 13, block; 14, call; 15, identifier:parts; 16, call; 17, string:"_"; 18, subscript; 19, expression_statement; 20, attribute; 21, argument_list; 22, attribute; 23, argument_list; 24, identifier:parts; 25, unary_operator; 26, assignment; 27, string:"."; 28, identifier:join; 29, identifier:parts; 30, identifier:fld_name; 31, identifier:split; 32, string:"."; 33, integer:1; 34, subscript; 35, binary_operator:"_" + parts[-1]; 36, identifier:parts; 37, unary_operator; 38, string:"_"; 39, subscript; 40, integer:1; 41, identifier:parts; 42, unary_operator; 43, integer:1
code: def es_field_sort(fld_name):
      """ Used with lambda to sort fields """
      parts = fld_name.split(".")
      if "_" not in parts[-1]:
          parts[-1] = "_" + parts[-1]
      return ".".join(parts)