Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: sorting the...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 5415 of 6266
Post > Topic >>

Re: sorting the chars in a string

by =?ISO-8859-2?Q?F=D6LDY_Lajos?= <foldy@[EMAIL PROTECTED] > Feb 11, 2008 at 04:37 PM

On Mon, 11 Feb 2008, elwood wrote:

>
>
> I've been trying to think of a simple way to alphabetically sort an
> individual string
>
> Say I have the string x="abdcf"
> Is there a way to sort it and return a new string which is in correct
> alphabetical order,
> and/or reverse alphabetical order.
>
> Maybe its obvious, but I havent worked with strings too much in IDL
> and I cant seem to find
> a way to do this (strsplit and stregex somehow??)
>
> Thanks,
> Elisha
>


Just for fun, you can do it without an explicit sort:

b=byte(x)
h=histogram(b, rev=r)
x=string(b[r[n_elements(r)-n_elements(b):*]])
or
x=string(b[reverse(r[n_elements(r)-n_elements(b):*])])

regards,
lajos
 




 7 Posts in Topic:
sorting the chars in a string
elwood <epolomsk@[EMAI  2008-02-11 06:39:53 
Re: sorting the chars in a string
Lasse Clausen <lasse@[  2008-02-11 07:02:34 
Re: sorting the chars in a string
elwood <epolomsk@[EMAI  2008-02-11 07:36:17 
Re: sorting the chars in a string
=?ISO-8859-2?Q?F=D6LDY_La  2008-02-11 16:37:13 
Re: sorting the chars in a string
elwood <epolomsk@[EMAI  2008-02-11 07:42:06 
Re: sorting the chars in a string
elwood <epolomsk@[EMAI  2008-02-11 07:36:32 
Re: sorting the chars in a string
Spon <christoph.blau@[  2008-02-11 08:23:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:13:23 CDT 2008.