Randomness in built-in .sort

mw mingwu at gmail.com
Tue Mar 23 21:22:25 UTC 2021


On Tuesday, 6 January 2009 at 01:18:21 UTC, bearophile wrote:
> Bill Baxter:
>
>>I use this all the time in NumPy in the form of "argsort" which 
>>returns a list of indices giving the sort order.  That can then 
>>be used as to index other arrays (thereby permuting them to the 
>>sorted order).
> order = npy.argsort(keys)
> sortedA = A[order]
> sortedB = B[order]<
>
> My dlibs already contain an efficient sorting routine, much 
> faster than the built in one.
>
> So to my dlibs I have just added sortedIndexes and remapOrder, 
> you can find their docs here: 
> http://www.fantascienza.net/leonardo/so/dlibs/func.html
>
> The code: http://www.fantascienza.net/leonardo/so/libs_d.zip
>
> The usage is very simple, sortedIndexes is similar to sorted():
>
> auto a =  [-5, 2, 3, 1, -11].dup;
> auto order1 = a.sortedIndexes();
> // now order1 == [4U, 0, 3, 1, 2]


I'm now looking for np.argsort, and found this post.

@bearophile, the doc page above is gone, although the zip file is 
still there (~10 years old), do you want to create a github repo, 
and contribute the code to dub (https://code.dlang.org/)?


BTW, does anyone know if there is a np.argsort function in some 
other d libraries?


Thanks.



More information about the Digitalmars-d mailing list