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

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

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:keywords set to Id
File size: 996 bytes
Line 
1;+
2; @file_comments
3;
4;
5; @categories
6;
7;
8; @param DIMS
9;
10;
11; @keyword INVERSE
12;
13;
14; @returns
15;
16;
17; @uses
18;
19;
20; @restrictions
21;
22;
23; @examples
24;
25;
26; @history
27;
28;
29; @version
30; $Id$
31;
32; @todo seb
33;
34;-
35
36
37function sortdim, dims, inverse=inverse
38;
39;   IDL> a=['x','y','t','z']
40;   IDL> b=a[sortdim(a)]
41;   IDL> print, a
42;   x y t z
43;   IDL> print, b
44;   x y z t
45;   IDL> print, b[sortdim(a,/inv)]
46;   x y t z
47;   IDL> a='xytz'
48;   IDL> print, sortdim(a)
49;              0           1           3           2
50;
51;
52;
53;
54  compile_opt idl2, strictarrsubs
55;
56   tosort = dims
57   if n_elements(tosort) eq 1 then $
58    tosort = string(reform(byte(tosort),1,(strlen(tosort))[0]))
59   tosort = strrepl(tosort,strwhere(tosort,'x'),'a')
60   tosort = strrepl(tosort,strwhere(tosort,'y'),'b')
61   tosort = strrepl(tosort,strwhere(tosort,'z'),'c')
62   tosort = strrepl(tosort,strwhere(tosort,'t'),'d')
63   tosort = uniq(tosort,sort(tosort))
64   if keyword_set(inverse) then tosort=sort(tosort)
65   return, tosort
66
67end
68;
69
Note: See TracBrowser for help on using the repository browser.