source: trunk/SRC/ToBeReviewed/HOPE/sortdim.pro @ 142

Last change on this file since 142 was 142, checked in by navarro, 18 years ago

english and nicer header (2a)

  • Property svn:keywords set to Id
File size: 820 bytes
Line 
1;+
2;
3; @todo seb
4;
5;-
6
7
8function sortdim, dims, inverse=inverse
9;
10;   IDL> a=['x','y','t','z']
11;   IDL> b=a[sortdim(a)]
12;   IDL> print, a
13;   x y t z
14;   IDL> print, b
15;   x y z t
16;   IDL> print, b[sortdim(a,/inv)]
17;   x y t z
18;   IDL> a='xytz'
19;   IDL> print, sortdim(a)
20;              0           1           3           2
21;
22;
23;
24;
25  compile_opt idl2, strictarrsubs
26;
27   tosort = dims
28   if n_elements(tosort) eq 1 then $
29    tosort = string(reform(byte(tosort),1,(strlen(tosort))[0]))
30   tosort = strrepl(tosort,strwhere(tosort,'x'),'a')
31   tosort = strrepl(tosort,strwhere(tosort,'y'),'b')
32   tosort = strrepl(tosort,strwhere(tosort,'z'),'c')
33   tosort = strrepl(tosort,strwhere(tosort,'t'),'d')
34   tosort = uniq(tosort,sort(tosort))
35   if keyword_set(inverse) then tosort=sort(tosort)
36   return, tosort
37
38end
39;
40
Note: See TracBrowser for help on using the repository browser.