Select to view content in your preferred language

How Do I Format TableFrameElement .sortFields Function

47
1
yesterday
ZoEast
by
New Contributor
 

Hello,

I am hoping to sort my Layout table element table_ele by the field "LABEL" but am unsure how to parameterize the function sortFields as shown in line 7. Any help would be appreciated. 🙂

mpf = arcpy.mp.ArcGISProject("CURRENT") # Select current map project

lyt = mpf.listLayouts(layout)[0] # Select layout

table_ele = lyt.listElements("MAPSURROUND_ELEMENT", "Table Frame")[0] # Search layout for first table frame

table_ele.sortFields()

 

0 Kudos
1 Reply
AlfredBaldenweck
MVP Regular Contributor

The documentation says it's a list of dictionaries.

So I'd assume like

# Select current map project
mpf = arcpy.mp.ArcGISProject("CURRENT") 

lyt = mpf.listLayouts(layout)[0] # Select layout
# Search layout for first table frame
table_ele = lyt.listElements("MAPSURROUND_ELEMENT", "Table Frame")[0] 

table_ele.sortFields([{"name":"Label", "ascending": True, "caseSensitive": True}, 
                      {"name":"Field2", "ascending": False, "caseSensitive": True}
                      ]
)
0 Kudos