How does ArcGIS Sort tool handle records that match for all specified fields?

646
1
07-22-2020 10:54 AM
MatthewLeonard
New Contributor III

I'm using ArcGIS Desktop 10.7.  Concerning the Sort (data management) tool (described here😞 Say I specify 3 sort fields, and there are records that have matching values for all 3. How does the tool decide which of those records are sorted first? Does it go by OBJECTID value, or another field? Is it random?

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

Esri's documentation doesn't address the question, likely because the behavior could vary by back-end datasource or DBMS.

Most, if not all, DBMSs only guarantee the result set order stated by an ORDER BY clause.  Any ordering outside of an ORDER BY clause may change between executions.  It doesn't mean the ordering between executions will change, just that it may change if the fields/columns aren't part of an ORDER BY clause.  The underlying reason is that a query optimizer is free to choose a different execution plan every time it executes a query, and fields/columns that aren't part of an ORDER BY clause may be processed or retrieved in a different order with different execution plans.