Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is argsort called argsort?

Tags:

numpy

So, it's an indirect sort that returns the indices that would sort an array. Why is it "argsort" (which makes some sense given that it takes an argument -- the type of sort to use) but not "indirect_sort" or something like that? Or get_sort_indexer?

like image 881
Anonymous Avatar asked Oct 20 '22 11:10

Anonymous


1 Answers

Googling for argsort gives numpy as first result, so it might indeed be a bit uncommon name. This might be something historic, apparently it already existed in 1997 in Numeric, a predecessor to Numpy.

I would guess they came up with that name as a parallel to argmax, which seems to be standard mathematical function that is implemented in many languages (numpy, mathematica, ...), even though the analogy is not perfect.

like image 140
Bas Swinckels Avatar answered Nov 17 '22 00:11

Bas Swinckels