[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistency: "sort" on UNIX <-> Windows



Daniel Luebbert wrote:
> I've been using the "sort" routine to sort an 2D-array by increasing
> values of its first column.
> The "sort" routine seems to behave differently in the UNIX and the
> Windows versions of IDL5.3.
> 
> Here is a little test routine I wrote:
> 
> ;**************************
> pro test_sort
> data = [[1,3], $
>         [2,5], $
>         [1,4], $
>         [4,7], $
>         [1,2] $
>         ]
> 
> print,"original: "
> print,data
> print,"sorted: "
> print,data[*,sort(data[0,*])]
> end
> ;**************************
> 
> The result on UNIX (Linux) is what I would expect:
> 
> ;**************************
> original:
> 
>        1       3
> 
>        2       5
> 
>        1       4
> 
>        4       7
> 
>        1       2
> 
> sorted:
> 
>        1       3
> 
>        1       4
> 
>        1       2
> 
>        2       5
> 
>        4       7
> 
> ;**************************
> 
> BUT: The result on Windows is different:
> 
> ;**************************
> original:
>        1       3
>        2       5
>        1       4
>        4       7
>        1       2
> sorted:
>        1       2
>        1       4
>        1       3
>        2       5
>        4       7
> ;**************************
> 
> In other words: The "sort" routine on Windows doesn't preserve the
> original order of entries which have the same value (see the 3
> "1"-values in my test data), but apparently rearranges them in a random
> way.
> 
> What I'd like to know is:
> How can it be that such a basic routine behaves differently in differnet
> implementations of IDL?
> 
> And, more importantly: can anybody tell me how to make the
> Windows-version of "sort" behave correctly,
> without writing my own routine for sorting?

Search for 'BSORT' at
http://www.astro.washington.edu/deutsch/idl/htmlhelp/index.html

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley