Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: i <= 0 ??
Date: Sun, 8 Nov 2009 16:17:01 +0000 (UTC)
Organization: Xoran Technologies
Lines: 18
Message-ID: <hd6qtt$ep5$1@fred.mathworks.com>
References: <hcfjrm$jcs$1@fred.mathworks.com> <hcfldp$pr1$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257697021 15141 172.30.248.38 (8 Nov 2009 16:17:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 8 Nov 2009 16:17:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:583360


"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hcfldp$pr1$1@fred.mathworks.com>...
> And you have not finish with another astonishing rule:
> 
> >> sort([0 1 -2])
> 
> ans =
> 
>     -2     0     1 
> 
>  >> sort([1i 1 -2])
> 
> ans =
> 
>    1.0000                  0 + 1.0000i  -2.0000          % 1 <= -2 !!!

Hazardous indeed. A likely pitfall is, for example, if you want to sort the result of an ifft() output. Often you expect the output to be real-valued, and would expect the sorting to be done according to the real-part only, but forget that the output will have a residual complex part due to numerical round-off.

I guess it's worth cooking up a realsort() function and getting into the habit of using that...