samedi 28 février 2015

How to determine the ordering of elements in a vector?

It seems strange, but I haven't found anything on the following problem: Given a vector x of length n, how can one construct a vector oo of length n such that x[oo[i]] (for i=1,..,n) is sorted. Requirements: only C functions in the standard library are allowed to be used and the code has to be fast (note: I'm not a C programmer but experienced in R. R has order() for this task).


I found the post here but this discusses sorting directly.


Aucun commentaire:

Enregistrer un commentaire