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

Last change on this file since 325 was 325, checked in by pinsard, 16 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:keywords set to Id
File size: 970 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;-
27function sortdim, dims, inverse=inverse
28;
29;   IDL> a=['x','y','t','z']
30;   IDL> b=a[sortdim(a)]
31;   IDL> print, a
32;   x y t z
33;   IDL> print, b
34;   x y z t
35;   IDL> print, b[sortdim(a,/inv)]
36;   x y t z
37;   IDL> a='xytz'
38;   IDL> print, sortdim(a)
39;              0           1           3           2
40;
41;
42;
43;
44  compile_opt idl2, strictarrsubs
45;
46   tosort = dims
47   if n_elements(tosort) eq 1 then $
48    tosort = string(reform(byte(tosort),1,(strlen(tosort))[0]))
49   tosort = strrepl(tosort,strwhere(tosort,'x'),'a')
50   tosort = strrepl(tosort,strwhere(tosort,'y'),'b')
51   tosort = strrepl(tosort,strwhere(tosort,'z'),'c')
52   tosort = strrepl(tosort,strwhere(tosort,'t'),'d')
53   tosort = uniq(tosort,sort(tosort))
54   if keyword_set(inverse) then tosort=sort(tosort)
55   return, tosort
56
57end
Note: See TracBrowser for help on using the repository browser.