Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: String comparison

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

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.

Simply:
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!

Cheers!


  • 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