octave-maintainers
[Top][All Lists]
Advanced

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

Re: stable sorts


From: Ben Abbott
Subject: Re: stable sorts
Date: Sat, 25 Aug 2012 18:44:53 -0400

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

I assume wiki has the correct definition?

"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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]