FUNCTION rank_array, index ;+ ; NAME: ; rank_array ; PURPOSE: ; Calculates rank array for a given index array ; CATEGORY: ; gen/idl/toolbox/math ; CALLING SEQUENCE: ; rank = rank_array(index) ; INPUTS: ; index array; type: integer ; index array, i.e. array of indices returned ; by the IDL sort function ; OUTPUTS: ; rank array; type: integer ; rank array ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; IsType ; PROCEDURE: ; The rank array inverts the index array. Applying rank to the sorted ; array returns the array back into its original order: A[rank[index]] = A ; MODIFICATION HISTORY: ; JAN-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- n = n_elements(index) r = make_array(n, type=IsType(index)) r[index] = lindgen(n) RETURN, r & END