Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
    
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
add comment

3 Answers

up vote 6 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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
add comment

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'
>>> 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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