a note about extendtable in Pro 2.0.1... got a bug I am documenting, The table doesn't update automagically if the project containing the table is open... even removing it and reopening it doesn't work. I will post a code sample when classes are over today. It is easy
intable 'OBJECTID' and 'fieldtosort' used in TableToNumpyArray call it 'a'
sort 'a' using argsort on 'a' 'fieldtosort' as the key field. this gives an 'idx' index
slice 'a' using 'idx ... a[idx] called 'result'
I change the dtype of the array here so that you get a new field name... this is the piece I will have to share later
but I think ...> a.dtype = [('OBJECTID'), '<i4'), ('Sorted_num', '<i4')] # IFFFF 'fieldtosort' is numeric, otherwise you just snag the dtype from array 'a' and change the fieldname as shown, but reuse the dtype
arcpy.da.ExtendTable(table path, 'OBJECTID', array a, 'OBJECTID')
Sounds complicated, but it is 3-4 lines of code.
I also have some code in my blog that does the fancy sorting (can't remember what it is called offhand)
ie sorteddata = [1, 1, 1, 2, 2, 3, 4]
conventional srt = [1, 2, 3, 4, 5, 6, 7]
whateverit is .... = [1, 1, 1, 4, 4, 6,7]
then there is another one as well
Sorts text as well as number and by default sorts multiple columns in the order provided
I should redo a blog on this once I get the 'ExtendTable' issue resolved for Pro 2.0.1