MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: No StringCompare in Mathematica?

  • To: mathgroup at
  • Subject: [mg67177] Re: [mg67148] No StringCompare in Mathematica?
  • From: gardyloo <gardyloo at>
  • Date: Sun, 11 Jun 2006 02:18:26 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

Hi, Steven,

   I knew I'd done this before somehow, and expected to have to wade 
back through a lot of old code to figure out how I'd done it. Turns out 
it was pretty simple. I'm not sure how fast the list sorting is, but 
perhaps this might help:


list = {"s1", "s3", "s2", "s1", "s5", "s0"}


{"s1", "s3", "s2", "s1", "s5", "s0"}




{6, 1, 4, 3, 2, 5}




{"s0", "s1", "s1", "s2", "s3", "s5"}

    You'll find, though, that for sxx with xx>=10, the usual sorting 
mechanism comes into play, and so s15<s2. Kind of annoying, but possible 
to work around, with concomitant slowdowns, of course.

           Hope that helps,
                                Curtis O.

Steven T. Hatton wrote:
> I wanted to sort a list of XMLElements based on the text in the third
> descendent of the element type used to form the list.  In order to set up
> the comparison predicate, I had to(?) form a list of the two candidate
> strings and compare it to the sorted version of itself.  The sort was
> fairly slow in executing.  I would like to have simply done s1 < s2, but
> Mathematica doesn't appear to support that.  Is there a way to get that
> functionality more simply than what I described?

Curtis Osterhoudt
PGP Key ID: 0x088E6D7A
Please avoid sending me Word or PowerPoint attachments

  • Prev by Date: Re: Mathematica doesn't know what it's doing.
  • Next by Date: Reordering limits for Plot3D
  • Previous by thread: No StringCompare in Mathematica?
  • Next by thread: Re: No StringCompare in Mathematica?