<?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: Sorting before continuing in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630762#M49104</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I see the .da has an editor session available.&amp;nbsp; If I use this will I not have to create a second .shp?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something along the lines of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; with arcpy.da.Editor(workspace) as edit:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Sort_management (in_dataset, out_dataset, sort_field)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this is the case, how do I close the edit session?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:50:03 GMT</pubDate>
    <dc:creator>TomKearns</dc:creator>
    <dc:date>2021-12-12T02:50:03Z</dc:date>
    <item>
      <title>Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630759#M49101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am interested in sorting via an attribute before running my script.&amp;nbsp; Currently I am trying to use an update cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.gp.UpdateCursor (in_dataset,"","","", "attribute D")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It does not appear to work when I use the next search cursor. I sort as above then call the next line, check the fid and it is still 0. I tried to refresh in an attempt to make the sort stick but as of yet it has not worked.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I have to use "Sort_management"?&amp;nbsp; I would like to complete the operation without creating a new .shp.&amp;nbsp; It seems that the lock Sort_management puts on the file prevents it from writing over its self.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 13:53:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630759#M49101</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T13:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630760#M49102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you trying to use a da cursor?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;sorted(arcpy.da.SearchCursor(table, 'atribute'))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 13:57:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630760#M49102</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-16T13:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630761#M49103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was not.&amp;nbsp; When I started the script I was unsure if it would be run on machines with only 10 so I used the old update cursor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:03:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630761#M49103</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T14:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630762#M49104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I see the .da has an editor session available.&amp;nbsp; If I use this will I not have to create a second .shp?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something along the lines of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; with arcpy.da.Editor(workspace) as edit:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Sort_management (in_dataset, out_dataset, sort_field)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this is the case, how do I close the edit session?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:50:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630762#M49104</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2021-12-12T02:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630763#M49105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is 'attribute' the name of your field? You should include more of your code to see what you are trying to accomplish.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:12:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630763#M49105</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-16T14:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630764#M49106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The LINKNO attribute counts up to 449 and it is the line with 449 as the attribute that I want the script to read first.&amp;nbsp; When I call the fid it still reads as fid 0, not 115 as I was shooting for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.UpdateCursor (stream_in,"","","", "LINKNO D")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count1 = arcpy.gp.GetCount_management(stream_in)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.SearchCursor(stream_in)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cursor.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fid = row.FID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "naming fid"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fid&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:50:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630764#M49106</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2021-12-12T02:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630765#M49107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you trying to extract one particular row from your data? Or are you trying to start at an arbitrary row and continue from that?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:43:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630765#M49107</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-16T14:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630766#M49108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to start at the highest LINKNO and the script will then move through the table row by row. This script will be run on multiple shape files and there is no way to tell ahead of time which fid the highest LINKNO will correspond to.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:50:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630766#M49108</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T14:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630767#M49109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The LINKNO attribute counts up to 449 and it is the line with 449 as the attribute that I want the script to read first.&amp;nbsp; When I call the fid it still reads as fid 0, not 115 as I was shooting for.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.gp.UpdateCursor (stream_in,"","","", "LINKNO D")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count1 = arcpy.gp.GetCount_management(stream_in)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor = arcpy.SearchCursor(stream_in)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cursor.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fid = row.FID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "naming fid"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fid&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;See this post for syntax using the sort in a normal cursor.&amp;nbsp; Examples for both hard coding the attribute and using a variable for it. &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/88186-To-select-a-record-based-on-the-highest-value-of-a-field" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/88186-To-select-a-record-based-on-the-highest-value-of-a-field&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;also, I see you are sorting your updateCursor, yet you are grabbing the cursor.next() on the cursor object created by the searchcursor.&amp;nbsp; I don't see a sort on the searchcursor, so should get the first fid each time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps try setting the cursor = to the update cursor and see if it grabs the correct value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:50:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630767#M49109</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T02:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630768#M49110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you, I had just found that same thread a few minutes ago and am trying to grab the FID using it.&amp;nbsp; There is something wrong with my syntax though as it keeps crashing.&amp;nbsp; I understand what you were saying about calling the wrong cursor, and will look at that as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;maxValue = arcpy.gp.SearchCursor(stream_in,"","","", "LINKNO D").next().getValue(FID)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 15:27:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630768#M49110</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T15:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630769#M49111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, here is working code to choose the appropriate fid.&amp;nbsp; Thanks for the help everybody.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uCursor = arcpy.gp.UpdateCursor (stream_in,"","","", "LINKNO D")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urow = uCursor.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fidStart = urow.FID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "fid start"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fidStart&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:50:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630769#M49111</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2021-12-12T02:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630770#M49112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That still didn't answer the question about sorting before processing though.&amp;nbsp; Now I can grab the fid of the highest value but I am still interested in sorting the whole table based on the values in the LINKNO column.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 15:49:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630770#M49112</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T15:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630771#M49113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uCursor = arcpy.gp.UpdateCursor (stream_in,"","","", "LINKNO D")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; urow = uCursor.next()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fidStart = urow.FID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "fid start"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fidStart

&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure what you mean here.&amp;nbsp; They way you have it above, the uCursor object IS your entire table sorted by LINKNO descending.&amp;nbsp; the uCursor.next() just grabs the next (in this case the first) value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for row in uCursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print row.FID

&lt;/PRE&gt;&lt;SPAN&gt;&amp;nbsp; Should print all your FID's sorted descending.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:50:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630771#M49113</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T02:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630772#M49114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes but my origional goal was to sort the whole table based on the LINKNO attribute and then run the rest of the script with the table sorted as such (the script creates a new attribute and fills it according to other variables).&amp;nbsp; That is why my initial cursor was in an UpdateCursor as opposed to SearchCursor.&amp;nbsp; What I was finding was that the table was no longer sorted when I proceded with the script. In thinking about it now, it makes sense due to it being only the cursor that is sorted, not the table.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To restate my problem hopefully to improve clarity:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am interested in sorting my table by an attribute and then proceding with my script.&amp;nbsp; I was attempting to do it using an UpdateCursor but found when I called the FIDs that the table was not sorted.&amp;nbsp; Ideally I could accomplish the sorting without creating a new .shp.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:39:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630772#M49114</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T16:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630773#M49115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your sorted updateCursor will allow you to "update" values in a field, and would be based on the "sorted" table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I.e, if you setValue of a new field = 1000, then when you look at your table, after the update, the "last" record (highest FID) would be updated to 1000 (since you've done a cursor.next(), you have the "first" row (in decending order) selected so would actually be the "last" row of the table).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if you create the new attribute field before you establish the updateCursor, you can easily update the record based on the sorted table.&amp;nbsp; Just do your updates before you exit the sorted updateCursor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;however, you can't make a table sort of a feature class permenant without creating a new dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The "order" of a shapefile is determined by the order that the features are added.&amp;nbsp; If you are actually after a "sorted" shapefile, not just a sorted table, you would want to use the arcpy.sort function which does create a new feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, could sort the shapefile into a new fc, delete your existing shapefile, then convert the FC back to shapefile with your original name.&amp;nbsp; That is, of course, if you really, for some reason need a shapefile, otherwise, you can just use the new FC (since output of Sort doesn't support shapefiles).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000057000000" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000057000000&lt;/A&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000057000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000057000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this doesn't get you going, maybe some input of what the other variables would be, and how you want it "filled" would give me a better idea.&amp;nbsp; Are these variables coming from other fields, static input, etc.?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:57:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630773#M49115</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-16T16:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting before continuing</title>
      <link>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630774#M49116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My problem may have been that I was exiting the update cursor and expecting the order to stick. I am not sure how to stay within the cursor, I have bunch of for loops that run after the reordering. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The rest of the code looks at the variable I am sorting by and another and then assigns a name to the line.&amp;nbsp; It then queries the next row and if it is part of the link it assigns it the same name, all the way down to 0.&amp;nbsp; Then it starts over at then next link without a name and repeats.&amp;nbsp; The cause for the question is that the longest line of links needed to be named first, they always have the highest LINKNO but do not necessaraly fall at FID 0.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LINKNO UPLINK NAME&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;449&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 448&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;448&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 446&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;447&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 445&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;446&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 410&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;445&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 403&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I gave in and just created a new .shp with "arcpy.Sort_management", it adds hastle but once coded it will be fine.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 17:22:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sorting-before-continuing/m-p/630774#M49116</guid>
      <dc:creator>TomKearns</dc:creator>
      <dc:date>2013-07-16T17:22:43Z</dc:date>
    </item>
  </channel>
</rss>

