help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting of words


From: SZABO Sandor
Subject: Re: Sorting of words
Date: Fri, 25 Feb 2000 17:53:44 +0000

Gabriel Panzenboeck wrote:

> On Fri, 25 Feb 2000, SZABO Sandor wrote:
>
> > Dear Octave users,
> >
> > I use Octave 2.0.16 and I have the following problem. I want to sort
> > alphabetically the words: "apple", "dog", "long". I tried with SORT
> > function without success. How can I solve this problem?
>
> a quick and dirty solution:
>
> a=['dog';'long';'apple']
> [s,i]=sort(toascii(a(:,1)))
> b=a(i,:)
>
> g.
>
> | address@hidden

Thanks for your answer. However there is a little problem.
In this special case your program works well. When I typed 'adog',
'along','aapple' instead of 'dog','long','apple' it produced a wrong
output.
b =

adog
along
aapple

Could you modify your "dirty solution" for general case?
Thanks.
          Sandor Szabo




-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

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