       Re: Simple String question

• To: mathgroup at smc.vnet.net
• Subject: [mg110698] Re: Simple String question
• From: "Christoph Lhotka" <lhotka at axp.mat.uniroma2.it>
• Date: Fri, 2 Jul 2010 07:27:18 -0400 (EDT)

```hi,

I would solve it by writing my own sort function:

sortfoo = (StringJoin @@ # & /@ (Sort /@
IntegerDigits /@ ToExpression /@ StringSplit[#, " "] /.
n_Integer :> ToString[n]) // Sort) /. {x_String, y_String} :>
x <> " " <> y &;

here is a tester function:

With[{foo =
ToString[RandomInteger[{100, 999}]] <> " " <>
ToString[RandomInteger[{100, 999}]]},
{foo -> sortfoo[foo]}]

regards,

christoph

On 02/07/2010 08:54, S. B. Gray wrote:
> I have strings like foo="623 715". foo will always be 3 digits, space, 3
> digits. I need to put each set of digits in numerical order and then put
> the two triples in order. This would give 157 236. There must be a
> simple way to do this, but I see nothing under string sorting.
>
> Steve Gray
>
>
>

```

• Prev by Date: Re: Simple String question
• Next by Date: Re: boolean variable with contours
• Previous by thread: Re: Simple String question
• Next by thread: Re: Simple String question