In the following code I meant to select rows from a table of cities named fc where the COUNTY='Socorro County' and ORDERED BY NAME:
fc="cities_copy"
where_selection=""""COUNTY"='Socorro County'"""
sql=(None,"ORDER BY NAME")
cursor=arcpy.da.SearchCursor(fc,["NAME","COUNTY"],where_selection,sql_clause=sql)
for row in cursor:
print("City Name: {0},\t {1}".format(row[0],row[1]))
From this code I get a list of cities by Name and County of those cities only in Socorro County, the original table selected from has cites with many other counties. I wish to order the selected cites by the NAME field, which I specified in my SQL variable. Instead I get this which is not ordered by NAME:
City Name: Veguita, Socorro County
City Name: Sabinal, Socorro County
City Name: Abeytas, Socorro County
City Name: Las Nutrias, Socorro County
City Name: Bernardo, Socorro County
Which is not ordered by NAME field. What am I doing wrong?