<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Order of da.UpdateCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208024#M16049</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two questions for you, Richard:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Does using &lt;SPAN style="font-family: 'courier new', courier;"&gt;OID@&lt;/SPAN&gt; for the field name let the cursor dynamically find the ObjectID field even if it isn't called ObjectID?&lt;/LI&gt;&lt;LI&gt;Could you explain the first colon in the list comprehension on line 8?&lt;/LI&gt;&lt;/OL&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14285249085635718" data-renderedposition="96.59375_30_870_16" jivemacro_uid="_14285249085635718" modifiedtitle="true"&gt;&lt;P&gt;(row[0:])&lt;/P&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Apr 2015 20:28:32 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2015-04-08T20:28:32Z</dc:date>
    <item>
      <title>Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208018#M16043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to manipulate the order the update cursor loops through my attribute table.&lt;/P&gt;&lt;P&gt;At the moment, my code looks as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor(lyr, column) as cursor: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = i&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i+1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where "lyr" is my layer and "column" is my column where the cursor needs to update the data. at the moment loops through and adds 1 as it needs but it does it in the order of the Object ID. I have an other column named "Nummer" where I have Numbers (Doulbe). The coursor should update the rows following those numbers (from 1 to x). How can I do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried "with arcpy.da.UpdateCursor(lyrkartenausschn, seitenzkartenausschn,"","","", sql_clause=(None, 'ORDER_BY Nummer A') as cursor: "&lt;/P&gt;&lt;P&gt;And also without all of those "", "", and also with "ORDER BY"&amp;nbsp; and with/without the "A". But it always gives me an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me fixing this part of the code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 19:15:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208018#M16043</guid>
      <dc:creator>SilvanStöckli</dc:creator>
      <dc:date>2015-04-07T19:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208019#M16044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is "ORDER BY", not "ORDER_BY" with the underscore between the two.&amp;nbsp; What is the exact message when you try:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14284372903843634 jive_macro_code jive_text_macro" data-renderedposition="29_8_912_16" jivemacro_uid="_14284372903843634"&gt;&lt;P&gt;with arcpy.da.UpdateCursor(lyrkartenausschn, seitenzkartenausschn, sql_clause=(None, "ORDER BY Nummer")) as cursor:&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 20:08:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208019#M16044</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-04-07T20:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208020#M16045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Joshua for helping me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copy pasted your Code and it says:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;&lt;P&gt;Runtime error&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 59, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;RuntimeError: An invalid SQL statement was used. [SELECT Seitenzahl, SHAPE_Area, SHAPE_Length FROM Kartenausschnitte_Vertrag ORDER BY Nummer]&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Line 59 is the first line of the for loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems to me as it would want to go trough other columns aswell (because Seitenzahl, SHAPE_Area are other columns in that table)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 06:14:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208020#M16045</guid>
      <dc:creator>SilvanStöckli</dc:creator>
      <dc:date>2015-04-08T06:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208021#M16046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;P&gt;Silvan:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is where an adaptation of my &lt;A _jive_internal="true" href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries" target="_blank"&gt;Turbo Charging Data Manipulation With Python Cursors and Dictionaries&lt;/A&gt; can help overcome the limitation of the DA cursor to control record order (which is a slow database operation even if it worked) and instead take advantage of the speed of a dictionary.&amp;nbsp; The dictionary keys can be sorted and will also let you quickly access them randomly as you write the data back to the cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this run a search cursor first through the entire record set and create a dictionary of sortable keys with initial values of 0.&amp;nbsp; Process the sorted dictionary keys and increase their values using a counter.&amp;nbsp; Finally run the update cursor and write to it using the dictionary.&amp;nbsp; I would use both your Nummer field and the ObjectID field values to be sure all keys are unique, since otherwise a repeated value in Nummer would mess up the counter.&amp;nbsp; (You are not limited to using the Nummer/ObjectID combination and this is how you can also set up relationships based on multi-field unique key values to overcome the limitations of single field joins).&amp;nbsp; The speed of this code will be virtually as fast as just running the update cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here is the code (replace 'COUNTER' with your actual counter name field):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="line-height: 1.5;"&gt;import arcpy&lt;/SPAN&gt;
&lt;SPAN style="line-height: 1.5;"&gt;lyr = YourLayer # replace this with your layer name&lt;/SPAN&gt;
fields = ['Nummer', 'OID@']
# set up a dictionary and counter
dict = {}
counter = 0
&lt;SPAN style="line-height: 1.5;"&gt;# Use list comprehension to build a dictionary of Nummer/ObjectID tuple keys&lt;/SPAN&gt;
dict = {(row[0:]):0 for row in arcpy.da.SearchCursor(lyr, fields)}
&lt;SPAN style="line-height: 1.5; font-size: 9pt;"&gt;# Sort the dictionary keys and increase the counter values based on the key order&lt;/SPAN&gt;
for value in sorted(dict.keys()):
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; dict[value] = counter
# Write back to the layer with an update cursor using the dictionary. Change 'COUNTER' to your counter field
fields = ['Nummer', 'OID@', 'COUNTER']
with arcpy.da.UpdateCursor(lyr, fields) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = dict[(row[0],row[1])]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:16:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208021#M16046</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T10:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208022#M16047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Richard! I don't know what to say but: you made my day! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It works perfectly and does exactly what I wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for providing the code the way I only have to replace two words.&lt;/P&gt;&lt;P&gt;I think I would have been able to write this code by myself because the list is something I don't understand yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you again! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 16:34:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208022#M16047</guid>
      <dc:creator>SilvanStöckli</dc:creator>
      <dc:date>2015-04-08T16:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208023#M16048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Silvan:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad I could help.&amp;nbsp; Dictionaries and lists provide powerful methods for working with data as you can see.&amp;nbsp; You should definitely invest some time in learning how to use them.&amp;nbsp; They can come in very handy for problems like this.&amp;nbsp; Have a great day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 17:05:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208023#M16048</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-08T17:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208024#M16049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two questions for you, Richard:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Does using &lt;SPAN style="font-family: 'courier new', courier;"&gt;OID@&lt;/SPAN&gt; for the field name let the cursor dynamically find the ObjectID field even if it isn't called ObjectID?&lt;/LI&gt;&lt;LI&gt;Could you explain the first colon in the list comprehension on line 8?&lt;/LI&gt;&lt;/OL&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14285249085635718" data-renderedposition="96.59375_30_870_16" jivemacro_uid="_14285249085635718" modifiedtitle="true"&gt;&lt;P&gt;(row[0:])&lt;/P&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 20:28:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208024#M16049</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-04-08T20:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208025#M16050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What version of ArcGIS are you using?&amp;nbsp; I am running ArcGIS 10.3, and I don't have any issues with using ORDER BY in a SQL clause for update cursors.&amp;nbsp; That said, I do seem to recall problems with it back in ArcGIS 10.1 and possibly 10.2.0.&amp;nbsp; Anyhow, I am just interested in whether your error might be related to the version you are running.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2015 22:00:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208025#M16050</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-04-08T22:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208026#M16051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please be clear.&amp;nbsp; Original update cursors and data access (da) module update cursors are two different things and may operate differently when it comes to the ORDER BY option.&amp;nbsp; da update cursors are fast and the only cursor type worth using.&amp;nbsp; So are you using the ORDER BY with a da module update cursor and if so what is the syntax?&amp;nbsp; The documentation does not cover this aspect of using the da cursor at all and it would be nice to know how to use it if it is an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said that, dictionaries can out perform the ORDER BY operation by a factor of at least 10 times the speed, since no disk access is involved, whereas Updating using the Order By operator has to retrieve and write to each record in order, which is very slow in my experience and severely impacted by the overall size of the table, whereas unsorted reading to a dictionary and sorting the dictionary is extremely fast.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 00:19:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208026#M16051</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-09T00:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208027#M16052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Blake:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Yes, using "OID@" will work for any field name that is identified as an OID type field.&amp;nbsp; So the names FID, OID, OBJECTID, etc. will all work as long as the field is typed as an OID field.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; (row[0:]) breaks down as follows:&lt;/P&gt;&lt;P&gt;A.&amp;nbsp; (...) creates a tuple (the outside parenthesis define this as a tuple).&lt;/P&gt;&lt;P&gt;B.&amp;nbsp; row[0:] reads the row pulled by the for loop within the list comprehension and iterates the listed fields in the field list parameter of the cursor.&amp;nbsp; row[0:] is the same as saying read all field values starting with the first field (0 based) and continuing to the last field for the current row.&amp;nbsp; The remainder of the list comprehension syntax understands to insert a comma between each field value since it is being comprehended within the tuple container.&amp;nbsp; So the full line is building a dictionary like:&lt;/P&gt;&lt;P&gt;dict = {(1,1):0,(2, 12):0,(3, 13):0,(4, 15):0,(4, 16):0,...};&lt;/P&gt;&lt;P&gt;The duplicate value of 4 in Nummer field is uniquely counted because it is being paired with the ObjectID value in each dictionary key.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 00:34:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208027#M16052</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-09T00:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208028#M16053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Joshua&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using 10.3 aswell. So I think this isn't the problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 06:41:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208028#M16053</guid>
      <dc:creator>SilvanStöckli</dc:creator>
      <dc:date>2015-04-09T06:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208029#M16054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Richard Fairhurst wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said that, dictionaries can out perform the ORDER BY operation by a factor of at least 10 times the speed, since no disk access is involved, whereas Updating using the Order By operator has to retrieve and write to each record in order, which is very slow in my experience and severely impacted by the overall size of the table, whereas unsorted reading to a dictionary and sorting the dictionary is extremely fast.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;10 times?&amp;nbsp; What backend storage are you using?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a quick test, I created a table with one million records and two fields.&amp;nbsp; One field held a randomly generated number and the other just an empty field to be updated in order of the other field.&amp;nbsp; When using an in_memory table, the ORDER BY approach was 300% faster.&amp;nbsp; When using a file geodatabases, the ORDER BY approach was 7% slower.&amp;nbsp; When using a personal geodatabases, the ORDER BY approach was the same.&amp;nbsp; Disregarding the in_memory example, file-based geodatabases don't take that much of a hit using ORDER BY with an update cursor (arcpy.da).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sorting of a dictionary might not involve any disk access, but the overall approach of the dictionary method surely does involve disk access.&amp;nbsp; Iterating over a search cursor to populate the dictionary hits the disk, and iterating over an update cursor to update records hits the disk again.&amp;nbsp; Although there is some overhead in having the database engine order the records, there is also overhead in iterating over the records twice instead of once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have access to Oracle or SQL Server this morning, so maybe ORDER BY does perform significantly worse in this case.&amp;nbsp; At least for file-based geodatabases, I don't see a significant difference in performance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 15:59:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208029#M16054</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-04-09T15:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208030#M16055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am basing my statements on ArcObjects cursors, not Python cursors, since I don't know how to make a da cursor sort.&amp;nbsp; da cursors seem more optimized than ArcObjects cursors, so that may be the reason you see such fast performance.&amp;nbsp; Several years ago I gave up on sorted cursors and never was willing to try them again, especially since there is virtually no documentation on how to set it up (figuring out ArcObjects was a pain and disappointment).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ORDER BY is not documented with da cursors.&amp;nbsp; Document how to use it in this post.&amp;nbsp; I am at a disadvantage, since I have explained my code so you can test my approach, but you have not shown or explained your da cursor syntax as far as I have seen so I cannot test your approach (if I missed it, please repeat it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My technique is actually more of a way to avoid doing joins and field calculations than it is to avoid sorting within a single feature class, but it fits this need as well.&amp;nbsp; In the case of joins and data transfers between feature classes/tables my approach is much faster than all other methods I have tried.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 16:52:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208030#M16055</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-09T16:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208031#M16056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, it's &lt;A href="http://stackoverflow.com/a/509295"&gt;slicing&lt;/A&gt;! Very cool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 17:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208031#M16056</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-04-09T17:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208032#M16057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it is slicing.&amp;nbsp; I remembered that term last night, but it did not come to mind when I was writing the response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2015 17:05:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208032#M16057</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-09T17:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208033#M16058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fair enough, now I understand the perspective you are coming from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you haven't seen it already, you might be interested in the &lt;A href="http://gis.stackexchange.com/questions/108807/how-is-the-data-access-cursor-performance-so-enhanced-compared-to-previous-versi" rel="nofollow noopener noreferrer" target="_blank"&gt;How is the data access cursor performance so enhanced compared to previous versions?&lt;/A&gt; thread over at StackExchange.&amp;nbsp; The first answer is from &lt;A href="https://community.esri.com/migrated-users/3016" target="_blank"&gt;Jason Scheirer&lt;/A&gt;​, one of the &lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.da&lt;/SPAN&gt; developers.&amp;nbsp; In his response he explains how they optimized the performance of the new cursors.&amp;nbsp; There is also a link to some benchmark results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although the&lt;SPAN style="font-family: courier new,courier;"&gt; sql_clause&lt;/SPAN&gt; documentation has remained the same, the &lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.da&lt;/SPAN&gt; &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/searchcursor-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;SearchCursor &lt;/A&gt;code samples have been expanded with ArcGIS 10.3 to include an SQL ORDER BY example.&amp;nbsp; The SearchCursor code sample is transferrable to the UpdateCursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;SPAN style="font-family: courier new,courier;"&gt;sql_clause&lt;/SPAN&gt; was buggy when the data access module was first released at ArcGIS 10.1.&amp;nbsp; I believe it was ArcGIS 10.2.1 where a couple bugs related to the &lt;SPAN style="font-family: courier new,courier;"&gt;sql_clause&lt;/SPAN&gt; were patched.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is a code snippet that creates a table with randomly generated values and then sorts against those values to update another field in order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import numpy
import random

fc = #table location in file geodatabase

random.seed(3.14)
l = []
for i in range(1000000):
&amp;nbsp;&amp;nbsp;&amp;nbsp; l.append((random.randint(0,100000000), 0.0))
narr = numpy.array(l, dtype=([('rand','i4'),('numb', 'f8')]))
arcpy.da.NumPyArrayToTable(narr, fc)

i = 1000
with arcpy.da.UpdateCursor(fc, ["rand", "numb"],sql_clause=(None,"ORDER BY rand")) as cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 1 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = i
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.updateRow(row)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:16:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208033#M16058</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T10:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208034#M16059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate getting information that brings me up to date on what is happening with da cursors in the latest versions of ArcGIS.&amp;nbsp; I don't have 10.3, and only recently got 10.2.1 installed.&amp;nbsp; I tried the Order By option at 10.1 with the release of the da cursor, but I gave up on it.&amp;nbsp; I have not tried it since then.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This has happened to me several times where I try something that should work in an early release and discover that it has serious issues that make it either fail or perform horribly.&amp;nbsp; Once I give up on code that fails me it can be hard to give Esri another chance.&amp;nbsp; Generally figuring out a workaround took so much effort that I resent the original method that should have worked for wasting so much of my time.&amp;nbsp; If a workaround is very effective, then even if the workaround is complex, I forget to even consider the possibility that the original approach that is simpler might have been fixed in the latest release.&amp;nbsp; Anyway, thanks for bringing me up to date.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 23:26:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208034#M16059</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-10T23:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Order of da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208035#M16060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand, completely.&amp;nbsp; The fact that some of the sql_clause bugs took until 10.2.1 to get addressed is, well, frustrating.&amp;nbsp; Oddly enough, I just tried my code snippet on an ArcGIS 10.1 SP1 machine and it worked.&amp;nbsp; I thought ORDER BY was also impacted by &lt;A href="http://support.esri.com/en/bugs/nimbus/TklNMDk0Nzk3"&gt;NIM094797&lt;/A&gt;, but that doesn't seem to be the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Overall, I have found the ArcPy documentation in the new 10.3 help to be either improved or expanded for quite a few objects, methods, functions, etc....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Apr 2015 01:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-da-updatecursor/m-p/208035#M16060</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-04-11T01:30:38Z</dc:date>
    </item>
  </channel>
</rss>

