Hello,
I'm working on a small project to label points based on a related table. I was able to get the labeling to work using this script:
def FindLabel([SIGN_ID]): strWhereClause = '"sign_ID" = \'{0}\''.format([SIGN_ID]) strpTable = "agencies.DATA_ADMIN7.signs" cursor = arcpy.da.SearchCursor(strpTable,"sign_order", strWhereClause) result = "" for row in cursor: strLabel = str(row[0]) result += strLabel + "\n" sort_fields = [["sign_order", "ASCENDING"]] return result.rstrip()
What I need to do now is sort the results of the labeling by a certain field (in ascending order). Currently, the labels are showing up based on objectID and display as 1,3,2, I need to have them show up based on a "sign_Order" field - 1,2,3.
Does anyone know how to sort the labels in this way?
Any help is greatly appreciated!!
Thanks,
Pat
See this blog on labeling with a related table. Creating Labels with Related Table Data Using this method you should be able to follow the dictionary with a list that you could sort and use the labels in the same way.