Select to view content in your preferred language

Implement natural sorting of text fields (numbers without leading zeros) across ArcGIS Pro

1100
2
04-09-2024 07:19 PM
Status: Open
Labels (1)
LindsayRaabe_FPCWA
Honored Contributor

IDEA: Implement natural sorting in text fields throughout ArcGIS Pro (attribute tables, dynamic table elements, etc).

USE CASE: When sorting numerical values in ArcGIS Pro, if these values are in a text field and are sorted in ascending order, it puts any number starting with a 1 (i.e. 101) before any number starting with a 2 (i.e. 20). I know I could add leading zero's to the numbers to get more accurate sorting, but I don't want to have to do this to then have to remove them in labelling (or to educate others to do this).

It would be better if text sorting treated numbers holistically (or at least up to the point that a non-numeric character occurs). 

Note - in below dynamic table element examples, sorting is done on the Rate column first then the Block column. 

LindsayRaabe_FPCWA_1-1712715472818.png

LindsayRaabe_FPCWA_2-1712715485339.png

I know it's better to store numbers in integer type fields, but in the above use case, blocks could be labelled with alpha delineators as well:

1A, 1B, 5, 2, 9, 3, 4A, 4B, 6, 7, 8, 10, 11A, 11B

...and I would want these to sort to match the numbers first then the letters (logically) and not end up with 9 after 11A and 11B:

1A, 1B, 2, 3, 4A, 4B, 5, 6, 7, 8, 9, 10, 11A, 11B. 

Currently these values would sort like this:

10, 11A, 11B, 1A, 1B, 2, 3, 4A, 4B, 5, 6, 7, 8, 9

2 Comments
DanPatterson

I might be a good idea to rename your idea to

"implement 'natural sort' for text fields"

This comes up a number of times, eg.

Better sorting of numbers in table frame - Esri Community

LindsayRaabe_FPCWA

@DanPatterson Thanks for the tip - I've made some edits to the post and title to better describe the request.