;+ ; ; @file_comments ; ; @categories ; ; @param DIMS ; ; @keyword INVERSE ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ; ; @todo seb ; ;- function sortdim, dims, inverse=inverse ; ; IDL> a=['x','y','t','z'] ; IDL> b=a[sortdim(a)] ; IDL> print, a ; x y t z ; IDL> print, b ; x y z t ; IDL> print, b[sortdim(a,/inv)] ; x y t z ; IDL> a='xytz' ; IDL> print, sortdim(a) ; 0 1 3 2 ; ; ; ; compile_opt idl2, strictarrsubs ; tosort = dims if n_elements(tosort) eq 1 then $ tosort = string(reform(byte(tosort),1,(strlen(tosort))[0])) tosort = strrepl(tosort,strwhere(tosort,'x'),'a') tosort = strrepl(tosort,strwhere(tosort,'y'),'b') tosort = strrepl(tosort,strwhere(tosort,'z'),'c') tosort = strrepl(tosort,strwhere(tosort,'t'),'d') tosort = uniq(tosort,sort(tosort)) if keyword_set(inverse) then tosort=sort(tosort) return, tosort end