comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: sorting the chars in a string
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: sorting the chars in a string [message #58632 is a reply to message #58631] Mon, 11 February 2008 07:37 Go to previous messageGo to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: sorting the chars in a string
Next Topic: the problem of making the example of externel calltest

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 15:56:40 PDT 2025

Total time taken to generate the page: 1.20220 seconds