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

Last change on this file since 231 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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