Last change
on this file since 509 was
495,
checked in by pinsard, 10 years ago
|
fix thanks to coding rules; typo; dupe empty lines; trailing blanks
|
-
Property svn:keywords set to
Id
|
File size:
964 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 | function 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 | compile_opt idl2, strictarrsubs |
---|
42 | ; |
---|
43 | tosort = dims |
---|
44 | if n_elements(tosort) eq 1 then $ |
---|
45 | tosort = string(reform(byte(tosort),1,(strlen(tosort))[0])) |
---|
46 | tosort = strrepl(tosort,strwhere(tosort,'x'),'a') |
---|
47 | tosort = strrepl(tosort,strwhere(tosort,'y'),'b') |
---|
48 | tosort = strrepl(tosort,strwhere(tosort,'z'),'c') |
---|
49 | tosort = strrepl(tosort,strwhere(tosort,'t'),'d') |
---|
50 | tosort = uniq(tosort,sort(tosort)) |
---|
51 | if keyword_set(inverse) then tosort=sort(tosort) |
---|
52 | return, tosort |
---|
53 | |
---|
54 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.