This question already has an answer here:
This code below auto-increments based on the FID/OID in the attribute table. How can I auto-increment a column based on a sort of another column? I don't want it to follow the FID/OID. Please advise.
rec=0 def autoIncrement(): global rec pStart = 1 #adjust start value, if req'd pInterval = 1 #adjust interval value, if req'd if (rec == 0): rec = pStart else: rec = rec + pInterval return rec