Makeindex Sort bug?

I am using Igor 6.37 (on windows) and I have a problem with Makeindex function

If mywave is (I copied an example found in a previous post)

1
3
5
2
4

the command
Duplicate mywave, index
MakeIndex mywave, index

Should create the index wave

0
2
4
1
3

but I get

0
3
1
4
2

What am I doing wrong?
How can I sort mywave with index (when it is corrent)?


Thanks

Simone
The result is correct.
Decoding the index wave you got, one obtains
mywave[0]=1
mywave[3]=2
mywave[1]=3
mywave[4]=4
mywave[2]=5

How do you get the "should" order? Probably there is a small error in reasoning.

For sorting, have a look at
displayhelptopic "IndexSort" and
displayhelptopic "Sorting"

HJ
The value in the index wave is used as an index into the unsorted wave. For example, the second row in index is "3". The value in mywave at row 3 is "2". You are thinking that index wave tells where the item in the same row of mywave belongs.

To sort mywave, you can use indexsort.

indexsort index, mywave
print mywave


produces mywave[0]= {1,2,3,4,5}