I’m feeling really dumb for asking this, but: is there an existing function in one of the more common packages which returns both the sorted data and a vector of the source indices? It’s simple enough to write:
Rgames> foo <- sample(1:10,10)
Rgames> bar <- sort(foo)
Rgames> bar_index <- sapply(1:10,function(jj)which(foo==bar[jj]))
“They call me Stormy^H^H^H^H^Htupid Monday,”
You could obtain the indices easily with:
This command will return a list including both indices and sorted data: