|
From: | Ed Meyer |
Subject: | Re: stable sorts |
Date: | Sat, 25 Aug 2012 18:55:58 -0700 |
I assume wiki has the correct definition?On Aug 25, 2012, at 6:18 PM, Michael D Godfrey wrote:
> On 08/25/2012 05:55 PM, Ben Abbott wrote:
>
>> ok. Thanks. The sort() in Matlab 2011b is stable.
>> i =
>>
>> 4
>> 1
>> 2
>> 3
>> 5
>
> Ben,
> I read this as NOT stable, just like Octave.
> Stable would give: 4 1 3 2 5
>
> Something wrong?
> Michael
"Stable sorting algorithms maintain the relative order of records with equal keys."
http://en.wikipedia.org/wiki/Sorting_algorithm#Stability
Since since x(2) and x(3) == 2, it looks to me as if Matlab's result is stable (relative order is maintained).
Ben
[Prev in Thread] | Current Thread | [Next in Thread] |