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

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

change *.pro file properties (del eof-style, del executable, set keywords Id

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