Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a shapefile and I want to change the order of the features. Is that possible?

share|improve this question
I don't really understand the question. Why do you want to reorder the records? Is it for display purposes? Graphically or for the attributes? Just a reminder to the question as well as some answers authors, nothing should rely on the order of the records as they are sent in a response to a query unless you provide an ORDER BY clause. It can change from a DBMS engine to another, between versions of a DBMS engine, etc. – GuillaumeC Feb 7 '11 at 8:09
You want to reorder the records for whatever purpose you need them to reordered... Such as building a graph (from the attribute table which will not respect the sort on-the-fly, but will respect when sorted permanently). And also for the issue of populating a sequential ID based on the sort. It needs to be sorted permanently before it will populate in the order; 1,2,3 etc – SaultDon Feb 7 '11 at 15:48
@GuillaumeC I want to sort the features in the shapefile because I'm embedding this shapefile in a mobile app. The app will display a list of features, and although I could do the sorting at load time, I'd prefer to have them sorted. I think it's a legitimate reason, isn't it? – tato Feb 7 '11 at 21:10
The goal is legitimate, the mean is not. If you need them sorted, use the result of a query, don't assume they are and will remain sorted. – GuillaumeC Feb 8 '11 at 7:49
up vote 6 down vote accepted

You can always open the attribute table in ArcMap and right click the columns header and select Sort Ascending.../Descending... for single fields.

For multiple fields you would instead click Advanced Sorting to select multiple fields.

NOTE: Adding, for instance, a sequential ID field based on the current sorting (which is temporary, stored only in this map/mxd) when using the above method will be ordered by the original OID/ObjectID of the feature class.

There is an ArcScripts available that will sort records permanently and output a new shapefile:

I do hope that when you state 'order of features' that this is the order found in the attribute table and not drawing order for the table of contents/symbology levels.

share|improve this answer
the script seems promising, as soon as I can try it I will mark the answer as 'the right one' – tato Feb 6 '11 at 23:42
it worked, as expected – tato Feb 12 '11 at 17:09

I don't know about Arc*, but for QGIS there is a Sort plugin:

enter image description here

share|improve this answer
Using this plugin I can only sort either in Ascending or in Descending direction. How to perform a custom sorting? For ex. id value 1, then 3, then 2 likewise. – Zia Jun 11 '15 at 8:19
@Zia that should be a new question – underdark Jun 11 '15 at 17:32
I'll compose then a new question soon. Thx. – Zia Jun 13 '15 at 12:43

If you have access to an arcinfo license, you can use the Sort in the (Data Management toolbox) which writes the records into a new shapefiles or gdb fc based spatial or attribute sorting

share|improve this answer
unfortunately it works with FGDB, not with shapes – tato Feb 7 '11 at 21:11
tato, the tool works with fgdb or shapefile as input and output, i've no idea what your comment above means. – gotchula Feb 8 '11 at 0:05

An utility software of MapServer (free and open-source) can sort shapes according to attributes values :

share|improve this answer

Here is a solution to rewrite a new and sorted shapefile using the GDAL/OGR command-line tool ogr2ogr.

For example, a shapefile orig.shp has a numeric field volume to sort on. This particular SQL statement does a reverse sort (with DESC) so that features with large volume values are drawn before (underneath) features with small values:

ogr2ogr -sql "SELECT * FROM orig ORDER BY volume DESC" sorted.shp orig.shp
share|improve this answer

Your Answer


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.