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


|