IDL sorting [message #56380] |
Wed, 17 October 2007 08:25  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
Hi,
I'm have that IDL sorting problem again: original subscript order is
not maintained when values are equal. Is there a more elegant way then
resorting each subarray of equal values on there original subscript?
Thanks.
|
|
|
Re: IDL sorting [message #56584 is a reply to message #56380] |
Tue, 06 November 2007 08:18  |
Conor
Messages: 138 Registered: February 2007
|
Senior Member |
|
|
On Nov 1, 7:02 pm, JD Smith <jdsm...@as.arizona.edu> wrote:
> On Thu, 18 Oct 2007 21:58:15 +0000, Karl Schultz wrote:
>> wlandsman <wlands...@gmail.com> wrote:
>>> On Oct 18, 2:30 pm, Karl Schultz <k...@io.frii.com> wrote:
>>>> Because it is not a *stable* sort. Stable sorting algorithms preserve
>>>> the order of equal keys.
>
>>>> > IDL just uses the sort algorithm of the underlying OS. As far as I
>>>> > am aware, the SORT function on Linux boxes *does* preserve the order
>>>> > of equal values, but that on Mac and Windows machines does not. I
>>>> > would be interested to hear if anyone finds any exceptions to this
>>>> > rule.
>
>>>> Are you using this SORT function from the command line? If so, you
>>>> are using a shell function or a sort program in your PATH. Someone
>>>> probably decided that a stable sort made more sense for people sorting
>>>> things from the command line or from shell scripts. Reasonable.
>
>>> I don't understand this paragraph. I am just using the IDL intrinisc
>>> SORT command. On every Linux box I have ever been on, it appears
>>> that the C lib sort algorithm used by IDL SORT() *is* stable, whereas
>>> it is *not* stable on Windows or MacOS.
>
>> When you said "SORT function on Linux boxes", I thought you meant from the
>> Linux command line. My bad.
>
>> So it looks like the qsort() implementation on the Linux distros you tried
>> happens to be stable. That's all.
>
> I side with Wayne: this platform difference has a real impact on many
> SORT-based algorithms. I understand the goal of re-using a tuned system
> QSORT, but going the extra step to get it to function the same on all
> IDL-supported systems would seem a no-brainer.
>
> JD
I think you have your answer: Just use a linux based operating
system! Then, you'll probably be using a stable sort and you won't
have to worry about this! I'm afraid I don't have any other thoughts :
(
|
|
|