Sort not MATLAB compatible

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Sort not MATLAB compatible

Eyal Doron
Hi Guys,

   Just thought you'd like to know. The following just broke a MATLAB
M file that was posted on the net:

octave:64> [a,b]=sort([1 2 3 4 1 2])
a =

  1  1  2  2  3  4

b =

  1  5  6  2  3  4


vs. MATLAB 4.0:

>[a,b]=sort([1 2 3 4 1 2])
a =
     1     1     2     2     3     4
b =
     1     5     2     6     3     4

Note the different indexing. Now, this is not strictly speaking a bug,
as both indexing schemes are correct. However, its an incompatibility.
Moreover, I think the MATLAB scheme is more logical.

Comments, anyone? John?

Eyal Doron