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!