>> From: Andy Jacobs [mailto:andyj@microsoft.com] >> Sent: Wednesday, June 23, 1999 19:00 >> To: 'Larry Rosler'; 'fwp@technofile.org' >> Subject: RE: [FWP] Finding the length of the longest string >> >> This would probably be MUCH slower... but it's kind of >> compact and fun. >> >> (sort map {length} @data)[-1]; > > It would be more fun if it sorted the lengths by their values instead of > lexicographically. Here's an unusual (but faster!) way of doing that: > > $len = unpack 'n' => > (sort map pack('n' => length) => @data)[-1]; > > I think those fancy commas are so expressive! > [snip benchmarks] > > Question: Why is [this sort] faster ... ? > > For the definitive answer, see the paper that Uri Gellman and I are > giving at te Perl Conference. > <URL:http://www.hpl.hp.com/personal/Larry_Rosler/sorting.html> damn fine work, larry. adjectively deserving of "elegant" ... -- @-------------------------------@--------------------@ | Michael Budash Consulting | (707) 252-7670 | | Perl, Javascript, PHP, MySQL | (603) 250-8679 fax | | Official Extropia Developer | mbudash@sonic.net | @-------------------------------@--------------------@ ==== Want to unsubscribe from Fun With Perl? ==== Well, if you insist... Send mail with body "unsubscribe" to ==== fwp-request@technofile.org