MathGroup Archive 2005

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

Search the Archive

Re: String comparison

  • To: mathgroup at
  • Subject: [mg55083] Re: String comparison
  • From: yasdfer at
  • Date: Fri, 11 Mar 2005 04:21:37 -0500 (EST)
  • References: <d0mo83$755$>
  • Sender: owner-wri-mathgroup at

Thanks for all your replies. Using OrderedQ definitely works!

Thought I would like to share with you another solution that I got from
Daniel Lichtbau at Wolfram.

alist[[Ordering[alist[[All, 3]]]]]

Timings on my machine is as follows:

In[1]:= alist = Table[{
    Random[], Random[Integer, {0, 1000}], \
FromCharacterCode[Table[Random[Integer, {65, 90}], {4}]]} , {1000000}];

In[2]:=Timing[Sort[alist, OrderedQ[{#1[[3]], #2[[3]]}] &]][[1]]
Out[2]:= 78.015 Second

In[3]:=Timing[alist[[Ordering[alist[[All, 3]]]]]][[1]]
Out[3]:=3.391 Second

At first it appears unbelievable how efficient the internal list
processing implementation of Mathematica is!


  • Prev by Date: how to set a global assumption setting Every Varaible I use is Real?
  • Next by Date: Re: Google's aptitude test equation
  • Previous by thread: Re: String comparison
  • Next by thread: Re: String comparison