I have dataset that has columns that need to be sorted based on multiple columns.

The first column contains a name and the second a number, the names are not unique. What I want is a NewID from 1 to 10 per name based on the descending value of the number. Like this: example

Any ideas how this can be done? Preferably in ArcMap.

  • Do you need a python script or step by step algorithm as an answer? May 12, 2017 at 10:20
  • Python script that can be used in field calculator would be nice.
    – Michiel
    May 12, 2017 at 10:24
  • 1
    ArcMap and FME require different solutions, which makes this question too broad. A Python solution requires you to provide the code you've developed to date. Please Edit the question.
    – Vince
    May 12, 2017 at 10:35
  • I removed FME, I currently do not have a python script.
    – Michiel
    May 12, 2017 at 11:23

2 Answers 2


I know you removed FME but for the record, a Sorter, sorting by the NameID and then secondly the number, followed by a Counter with the Counter ID set to the value of the NameID attribute will do exactly what you want.


This is will not answer your question but it might help you to solve your problem. Here is how to sort lists in python:

import pprint
table = [

print 'Before sorting:'
print '[OBJECTID, NameID, Number]'

print 'After sorting:'
print '[OBJECTID, NameID, Number]'
    sorted(table, key=lambda x: (x[1], x[2]))

Excetuting this script gives:

Before sorting:
[OBJECTID, NameID, Number]
[[1, 'H', -1],
 [2, 'D', 2],
 [3, 'D', 8],
 [4, 'D', 1],
 [5, 'H', 68],
 [6, 'H', 97],
 [7, 'H', 88]]

After sorting:
[OBJECTID, NameID, Number]
[[4, 'D', 1],
 [2, 'D', 2],
 [3, 'D', 8],
 [1, 'H', -1],
 [5, 'H', 68],
 [7, 'H', 88],
 [6, 'H', 97]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.