# ArcGIS 10 attribute table sort issue

what is the solution for this funky sorting Esri does in attribute tables with decimal places values... screen shot: http://i.imgur.com/0fqvF.png attribute table funky sort

-
Based on character positioning and sort results, I'd say MP is a text-type field. See answers re:character/text fields; Emily and I posted similar answers at the same time. – user3461 Aug 23 '11 at 18:41

It looks like MP is a character field, thus the weird sort. That sort looks normal for a character field. Try creating a new field, e.g. "MP_Num", as a numeric field, then calculate the values of MP_Num based on String-to-Number conversion of MP.

edit: I just noticed the ET_STATION field looks to be the numeric equivalent of MP, so you may not need to make a new field. Try sorting on ET_STATION.

-

What type is your field? If it's a text type, it will alphabetise it and therefore put everything starting with 1 first. Make a new field of a numerical type and it will sort properly.

edit: Also I just tested this on a table of my own with decimal places of type DOUBLE and it does not sort like this. But it does do it for the text label field I have.

-
Thanks Kevin and Emily, i knew it was something simple like that... screenshot: i.imgur.com/E5IFv.png – sirgeo Aug 23 '11 at 18:44

Your field is a text field and if you want to sort it properly, then it needs to be padded with zeros. There are various ways of doing this, an example is shown here which can be implemented within the field calculator if using ArcMap and I am sure other programs that support Python or Python-like syntax

EDIT

Then you can always use zfill to pad your rows if you are using the field calculator and the Python parser, you just .

``````>>> "17.98".zfill(8)
'00017.98'
``````

eg, convert to a string then pad

``````>>> a = 17.98
>>> b = str(a).zfill(8)
>>> b
'00017.98'
>>>
``````
-