MathGroup Archive 2006

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

Search the Archive

Re: No StringCompare in Mathematica?


s1="bzcxg";
s2="bzfy";

OrderedQ[{s1,s2}]

True

OrderedQ[{s2,s1}]

False

Sort[{s1,"a",s2}]

{a,bzcxg,bzfy}

Sort[{s1,"a",s2},OrderedQ[{#1,#2}]&]

{a,bzcxg,bzfy}

Sort[{s1,"a",s2},!OrderedQ[{#1,#2}]&]

{bzfy,bzcxg,a}


Bob Hanlon

---- "Steven T. Hatton" <hattons at globalsymmetry.com> 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?
> -- 
> http://www.mathematica-users.org/
> http://www.ifi.unizh.ch/math/bmwcs/master.html
> http://www.w3.org/Math/
> http://230nsc1.phy-astr.gsu.edu/hbase/hframe.html
> 

--

Bob Hanlon
hanlonr at cox.net



  • Prev by Date: Re: Simple question from a biologist
  • Next by Date: ? about Rule (rewritten)
  • Previous by thread: Re: No StringCompare in Mathematica?
  • Next by thread: Re: No StringCompare in Mathematica?