One line???
print join("",map
{tr/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/RWQOJMVAHBSGZXNTCIE
KUPDYFLrwqojmvahbsgzxntciekupdyfl/;$_}(sort(map
{tr/RWQOJMVAHBSGZXNTCIEKUPDYFLrwqojmvahbsgzxntciekupdyfl/ABCDEFGHIJKLMNOPQRS
TUVWXYZabcdefghijklmnopqrstuvwxyz/;$_}(<DATA>))));
__DATA__
Bock, Audie E.
Bustamante, Cruz M.
Feinstein, Dan
Flynt, Larry
Kennedy, Edward Thomas
Nave, Paul James
Novello, Donald A.
-----Original Message-----
From: KEVIN ZEMBOWER [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 3:16 PM
To: [EMAIL PROTECTED]
Subject: California ballot sort algorithm?
Here's a sure sign of someone with too much time on his hands:
I was curious how to implement an algorithm in perl to sort the candidates
in California's recall ballot. According to the news, here's the sort order:
RWQOJMVAHBSGZXNTCIEKUPDYFL
So, for instance, if STDIN is a cat of the file of candidates' names:
Bock, Audie E.
Bustamante, Cruz M.
Feinstein, Dan
Flynt, Larry
Kennedy, Edward Thomas
Nave, Paul James
Novello, Donald A.
STDOUT would be the sorted list:
Bock, Audie E. # Because O comes before U
Bustamante, Cruz M.
Novello, Donald A. # Because O comes before A
Nave, Paul James
Kennedy, Edward Thomas
Feinstein, Dan # Because E comes before L
Flynt, Larry
(if I did it correctly).
So, what's the most perl-ish way to write such a beast? Bonus points for a
one-liner.
-Kevin
-----
E. Kevin Zembower
Unix Administrator
Johns Hopkins University/Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD 21202
410-659-6139
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]