I am trying to use FieldMappings in Arcpy to re-order columns in a feature class. I perform a variety of functions on this feature class in my script including adding fields, renaming fields, doing a spatial join, and adding an attribute rule. After all of this, I would like to re-order the fields, but I have not been able to figure out a way to do that. I was able to use the field mappings argument within the spatial join tool (shown below) but I have not been able to do it using FieldMappings().
arcpy.analysis.SpatialJoin(
target_features = fc_bl_temp,
join_features = fc_tr_70_out_j,
out_feature_class = fc_bl_out,
join_operation = "JOIN_ONE_TO_ONE",
join_type = "KEEP_ALL",
field_mapping = 'STATE70 "STATE70" true true false 2 Text 0 0, First,#,fc_bl_temp,STATE70,0,2;COUNTY70 "COUNTY70" true true false 3 Test 0 0, First,#,fc_bl_tem,COUNTY70,0,3;TRACT80 "TRACT80" true true false 10 Text 0 0, First,#,fc_bl_temp,TRACT80,0,10;BLK70 "BLK70" true true false 3 Text 0 0,First,#,fc_bl_temp,BLK70,0,3;Shape_Length "Shape_Length" false true true 8 Double 0 0,First,#,fc_bl_temp,Shape_Length,-1,-1;Shape_Area "Shape_Area" false true true 8 Double 0 0,First,#,fc_bl_temp,Shape_Area,-1,-1',
match_option="HAVE_THEIR_CENTER_IN",
search_radius = None,
distance_field_name = ""
)
Most of the documentation I'm seeing is for combining two feature classes to create a new one or merge of some sort, but I'm struggling to translate those examples to my use case with a single feature class that I am not trying to change in any other way. Does anyone have any ideas for how to approach re-ordering ~10 fields in one feature class?