Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Array manipulation question
Date: Tue, 21 Aug 2007 18:38:23 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 22
Message-ID: <fafbev$dku$1@fred.mathworks.com>
References: <fafah8$ot$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187721503 13982 172.30.248.37 (21 Aug 2007 18:38:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 21 Aug 2007 18:38:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:424823



Adam:
<SNIP error of <sort>s...

> I can't use the sort function because it re-orders the 
array and I would lose the index information...

why?

     v=[3,4,1,2,5].';
     [vs,vx]=sort(v);
     n=3;
     r=[vs(1:n),vx(1:n)];
     disp(r);

also, look at <loren shure>'s recent hootenanny of <sort>s

http://blogs.mathworks.com/loren/2007/08/21/reversal-of-a-
sort/

to sort things out...

us