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 17:55:06 -0400

On Aug 25, 2012, at 3:53 PM, Michael D Godfrey wrote:

> On 08/25/2012 02:54 PM, Ben Abbott wrote:
>> I'm not sure I'm understanding this, but if you can provide an example, I'll 
>> try it out using the most recent Matlab release.
>> 
>> Ben
>> 
> Just try:
> 
>  x = [3 2 2 5 1];
> [s,i]=sort(x',1,'descend')
> 
> s =
> 
>      5
>      3
>      2
>      2
>      1
> 
> 
> i =
> 
>      4
>      1
>      2
>      3
>      5
> 
> >
> And, see if your i vector is the same as above.
> Stable sort would give: 4 1 3 2 5
> 
> Michael

ok. Thanks.  The sort() in Matlab 2011b is stable.

 x = [3 2 2 5 1];
[s, i] = sort (x', 1, 'descend')

s =

     5
     3
     2
     2
     1


i =

     4
     1
     2
     3
     5

Ben



reply via email to

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