Sorting attribute tables by Python

6295
11
Jump to solution
01-03-2016 02:51 PM
CemAkkus2
New Contributor II

Hello there!

In new ArcGIS version, sorting is now limited to 1 field. I don't have an advanced license and I need to sort my attribute table based on 2 fields. I was wondering if there is a python script for 2 field sort.

Thanks!

Cem

0 Kudos
1 Solution

Accepted Solutions
WesMiller
Regular Contributor III

You could also use Sort—Help | ArcGIS for Desktop if you desire to create a copy of the table that is sorted by multiple fields.

View solution in original post

11 Replies
DanPatterson_Retired
MVP Emeritus

Sorting records in a table by multiple fields—Help | ArcGIS for Desktop  this doesn't work?  And of course sorts aren't permanent in any event

CemAkkus2
New Contributor II

Thanks for the reply Dan,

I forgot to mention that I need to sort the table permanently. The method you mention is a temporary sort so it does not change the table's original order.

Best,
Cem

WesMiller
Regular Contributor III

You could also use Sort—Help | ArcGIS for Desktop if you desire to create a copy of the table that is sorted by multiple fields.

CemAkkus2
New Contributor II

Thanks for the reply Wes,

I found that page after I posted. However, there is still a problem with "Python Window" version. I get this warning:

Runtime error  Traceback (most recent call last):   File "<string>", line 6, in <module>   File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 4351, in Sort     raise e ExecuteError: ERROR 000824: The tool is not licensed.

>>>

It seems ArcGIS requires Advanced License for advance permanent sorting in ArcGIS environment. However, I tested stand-alone Python script version and finally that one worked well.

Best,

Cem

WesMiller
Regular Contributor III

Yes to sort by shape or multiple fields requires an Advanced license see below.

License:

For the Field(s) parameter, sorting by the Shape field or by multiple fields is only available with anAdvanced license. Sorting by any single attribute field (excluding Shape) is available at all license levels.

0 Kudos
DanPatterson_Retired
MVP Emeritus

ahhhh, but then there is numpy

WesMiller
Regular Contributor III

I'm waiting for you to open the group

0 Kudos
CemAkkus2
New Contributor II

However, advanced sort still doable with stand-alone python script without advanced license.. which is good

0 Kudos
WesMiller
Regular Contributor III

Just so you are aware. It is likely that you have a license manager and an Advanced license is available when you run your python script. I am unable to locate the documentation to support this,but I've read that  arcpy gets the highest license available unless you explicitly set the license.

0 Kudos