I am having a problem with adding sequential numbers to the new column based on other sorted value. I would like to use 'Sort by' column to be able to generate numbers in the 'Required number'column.
I have a script listed below (Field calculator) that allows me to generate numbers in 'Script used' column. Unfortunately, the numbers start from 0 instead of 11.
mxd = arcpy.mapping.MapDocument("CURRENT")
lr=arcpy.mapping.ListLayers(mxd)[0]
tbl=arcpy.da.TableToNumPyArray(lr,("objectid","MapOrderNum"))#MapOrderNum is a field that you want to use to sorb by
bs=sorted(tbl,key=lambda x: x[1])
aDict={}
for i,row in enumerate(bs):
aDict[row[0]]=i
def sortSeq(objectid):
return aDict[objectid]
sortSeq ( !OBJECTID!)

for i,row in enumerate(bs, 11)instead offor i,row in enumerate(bs)– ahmadhanb Jan 23 '19 at 11:48return aDict[objectid]+11. You can use da.SearchCursor instead of TableToNumPyArray, not sure what will be faster:tbl = [i for i in arcpy.da.SearchCursor(lr, ["OID@","MapOrderNum"])]. Will be a list of tuples which you can sort the same way. – BERA Jan 23 '19 at 12:22