# Calculating sequential numbers into sorted table not dependent on OBJECTID? [duplicate]

This question already has an answer here:

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)

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)
aDict={}
for i,row in enumerate(bs):
aDict[row]=i
def sortSeq(objectid):
return aDict[objectid]

sortSeq ( !OBJECTID!)
`````` ## marked as duplicate by FelixIP, whyzar, ahmadhanb, Jochen Schwarze, jbalkJan 23 at 21:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• Try to use `for i,row in enumerate(bs, 11)` instead of `for i,row in enumerate(bs)` – ahmadhanb Jan 23 at 11:48
• Or `return 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 at 12:22