[scilab-Users] gsort function

Mathieu Dubois mathieu.dubois at limsi.fr
Wed Nov 17 18:06:30 CET 2010


Hello,

Do you want to sort every column (in its own order)? If so I think you 
should use gsort(D, 'c').

If you just want to sort 1 column you could use gsort(D(:, j), 'c').

Last but not least you can sort one column (as above) and use the vector 
k (return by gsort) to permute the other columns (so each row is preserved).

HTH,
Mathieu
On 11/17/2010 02:40 PM, Carrico, Paul wrote:
>
> Dear all,
>
> Sort algorithms are rather new for me ...
>
> In the example herebellow and after some tests, I've noticed that the 
> matrix is sorted from the 1rst column :
>
> - is it possible to choose the column to sort ?
>
> - otherwise does it mean it's necessary to permute the desired column 
> with the first one to sort ?
>
> Thanks in advance
>
> Cheers
>
> Paul
>
> ########
> mode(0);
> clearglobal();
>
> D = [
> 1 0 3 11 10 13;
>  4 9 6 -1 -1 0;
>     17 8 39 9 -451 3;
>     10 110 -12 1 -9 45 ;
>     -13 514 15 78 -99 3]
>
> D_lr = gsort(D,'lr','i')
> --------------------------------------------------------------------------------
>
>
> Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.
>
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.
>
>    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20101117/6b36d693/attachment.htm>


More information about the users mailing list