<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Sort by Library of Congress call number in Perl</title>
	<atom:link href="http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/</link>
	<description>Website of Joshua McGee</description>
	<pubDate>Sat, 22 Nov 2008 17:50:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Library of Congress Call Number Sort in PHP</title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-48533</link>
		<dc:creator>Library of Congress Call Number Sort in PHP</dc:creator>
		<pubDate>Tue, 12 Aug 2008 20:36:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-48533</guid>
		<description>&lt;!--%kramer-ref-pre%--&gt;[...] needed a function that will compare Library of Congress call numbers. I found a function in PERL to do this on Joshua McGees's site, but I needed it in PHP and our call numbers use a space instead of a period for some of the [...]&lt;!--%kramer-ref-post%--&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://dev.wp-plugins.org/wiki/Kramer"><img src="http://www.mcgees.org/wp-content/plugins/kramer.php?kramer=gif-icon" class="technorati-balloon" alt="Kramer auto Pingback" style="border:0;" /></a>[...] needed a function that will compare Library of Congress call numbers. I found a function in PERL to do this on Joshua McGees&#8217;s site, but I needed it in PHP and our call numbers use a space instead of a period for some of the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Clark</title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-25154</link>
		<dc:creator>Tom Clark</dc:creator>
		<pubDate>Mon, 30 Jul 2007 13:11:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-25154</guid>
		<description>I get it...sorry...like I said, a newbie.  Thanks for responding.

TC</description>
		<content:encoded><![CDATA[<p>I get it&#8230;sorry&#8230;like I said, a newbie.&nbsp; Thanks for responding.</p>
<p>TC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua <i>(Site Owner)</i></title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-25071</link>
		<dc:creator>Joshua <i>(Site Owner)</i></dc:creator>
		<pubDate>Sun, 29 Jul 2007 01:37:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-25071</guid>
		<description>Tom, I don't think so.  The first line, commented out, shows what was "passed" into the script.  The second line, also commented out, shows what one gets after the line is chopped up, or "parsed".  But that's Geoff's modification of my code, not mine.</description>
		<content:encoded><![CDATA[<p>Tom, I don&#8217;t think so.&nbsp; The first line, commented out, shows what was &#8220;passed&#8221; into the script.&nbsp; The second line, also commented out, shows what one gets after the line is chopped up, or &#8220;parsed&#8221;.&nbsp; But that&#8217;s Geoff&#8217;s modification of my code, not mine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Clark</title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-24934</link>
		<dc:creator>Tom Clark</dc:creator>
		<pubDate>Fri, 27 Jul 2007 14:53:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-24934</guid>
		<description>I'm a newbie looking forward to making this work.  If it does it'll save me a ton of time at my library.

Question:  Shouldn't the phrase:

       # print “A passed: $a\nB passed: $b\n”;

use 'parsed' instead of 'passed' ?  

or conversely for the subsequent phrase

       # print “A parsed: $resultA\nB parsed: $resultB\n”;

Perhaps I don't yet understand enough about Perl.

TC</description>
		<content:encoded><![CDATA[<p>I&#8217;m a newbie looking forward to making this work.&nbsp; If it does it&#8217;ll save me a ton of time at my library.</p>
<p>Question:&nbsp; Shouldn&#8217;t the phrase:</p>
<p>&nbsp; &nbsp; &nbsp;  # print “A passed: $a\nB passed: $b\n”;</p>
<p>use &#8216;parsed&#8217; instead of &#8216;passed&#8217; ?&nbsp; </p>
<p>or conversely for the subsequent phrase</p>
<p>&nbsp; &nbsp; &nbsp;  # print “A parsed: $resultA\nB parsed: $resultB\n”;</p>
<p>Perhaps I don&#8217;t yet understand enough about Perl.</p>
<p>TC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua <i>(Site Owner)</i></title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-268</link>
		<dc:creator>Joshua <i>(Site Owner)</i></dc:creator>
		<pubDate>Mon, 14 Aug 2006 23:10:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-268</guid>
		<description>Yes, it sure did.  It stripped out the backslashes before the dots, too.  Thanks for catching that.</description>
		<content:encoded><![CDATA[<p>Yes, it sure did.&nbsp; It stripped out the backslashes before the dots, too.&nbsp; Thanks for catching that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Sinclair</title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-267</link>
		<dc:creator>Geoff Sinclair</dc:creator>
		<pubDate>Mon, 14 Aug 2006 21:58:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-267</guid>
		<description>Here's an example with a little more context. Hopefully it's useful for newbies! I've added one more element to the sort, because our library sometimes makes additions after the year.

&#62;&#62;&#62;&#62;

my @lcList = ('DK602.3.B76 1996', 'Q335.P416 1994', 'DK602.3.B76 1996a -text', 'QA76.73.P22W35 1991', 'RS75.P5', 'DA870.F64', 'DK602.3.B76 1996b -disc');

$beforeList = join ("\n", @lcList);
print "Before:\n$beforeList\n\n";

my @result = sort by_lc_number @lcList;
$afterList = join ("\n", @result);

print "\nAfter:\n$afterList\n\n";

sub by_lc_number {

	# print "A passed: $a\nB passed: $b\n";
	
	$a =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;
	@a = ($1,$2,$3,$4,$5,$6,$7,$8);
	$b =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;
	@b = ($1,$2,$3,$4,$5,$6,$7,$8);

	# $resultA = join ("::", @a);
	# $resultB = join ("::", @b);
	# print "A parsed: $resultA\nB parsed: $resultB\n";

	return
	$a[0] cmp $b[0]
	    &#124;&#124;
	$a[1] &#60;=&#62; $b[1]
	    &#124;&#124;
	$a[2] cmp $b[2]
	    &#124;&#124;
	"0.$a[3]" &#60;=&#62; "0.$b[3]"
	    &#124;&#124;
	$a[4] cmp $b[4]
	    &#124;&#124;
	"0.$a[5]" &#60;=&#62; "0.$b[5]"
	    &#124;&#124;
	$a[6] &#60;=&#62; $b[6]
	    &#124;&#124;
	$a[7] cmp $b[7]
	    ;
}</description>
		<content:encoded><![CDATA[<p>Here&#8217;s an example with a little more context. Hopefully it&#8217;s useful for newbies! I&#8217;ve added one more element to the sort, because our library sometimes makes additions after the year.</p>
<p>&gt;&gt;&gt;&gt;</p>
<p>my @lcList = (&#8217;DK602.3.B76 1996&#8242;, &#8216;Q335.P416 1994&#8242;, &#8216;DK602.3.B76 1996a -text&#8217;, &#8216;QA76.73.P22W35 1991&#8242;, &#8216;RS75.P5&#8242;, &#8216;DA870.F64&#8242;, &#8216;DK602.3.B76 1996b -disc&#8217;);</p>
<p>$beforeList = join (&#8221;\n&#8221;, @lcList);<br />
print &#8220;Before:\n$beforeList\n\n&#8221;;</p>
<p>my @result = sort by_lc_number @lcList;<br />
$afterList = join (&#8221;\n&#8221;, @result);</p>
<p>print &#8220;\nAfter:\n$afterList\n\n&#8221;;</p>
<p>sub by_lc_number {</p>
<p>	# print &#8220;A passed: $a\nB passed: $b\n&#8221;;</p>
<p>	$a =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;<br />
	@a = ($1,$2,$3,$4,$5,$6,$7,$8);<br />
	$b =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;<br />
	@b = ($1,$2,$3,$4,$5,$6,$7,$8);</p>
<p>	# $resultA = join (&#8221;::&#8221;, @a);<br />
	# $resultB = join (&#8221;::&#8221;, @b);<br />
	# print &#8220;A parsed: $resultA\nB parsed: $resultB\n&#8221;;</p>
<p>	return<br />
	$a[0] cmp $b[0]<br />
	&nbsp; &nbsp; ||<br />
	$a[1] &lt;=&gt; $b[1]<br />
	&nbsp; &nbsp; ||<br />
	$a[2] cmp $b[2]<br />
	&nbsp; &nbsp; ||<br />
	&#8220;0.$a[3]&#8221; &lt;=&gt; &#8220;0.$b[3]&#8221;<br />
	&nbsp; &nbsp; ||<br />
	$a[4] cmp $b[4]<br />
	&nbsp; &nbsp; ||<br />
	&#8220;0.$a[5]&#8221; &lt;=&gt; &#8220;0.$b[5]&#8221;<br />
	&nbsp; &nbsp; ||<br />
	$a[6] &lt;=&gt; $b[6]<br />
	&nbsp; &nbsp; ||<br />
	$a[7] cmp $b[7]<br />
	&nbsp; &nbsp; ;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Sinclair</title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-266</link>
		<dc:creator>Geoff Sinclair</dc:creator>
		<pubDate>Mon, 14 Aug 2006 21:55:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-266</guid>
		<description>Thanks!! You're missing the backslashes before the d's. Did WordPress strip them out?</description>
		<content:encoded><![CDATA[<p>Thanks!! You&#8217;re missing the backslashes before the d&#8217;s. Did WordPress strip them out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Sinclair</title>
		<link>http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/#comment-265</link>
		<dc:creator>Geoff Sinclair</dc:creator>
		<pubDate>Mon, 14 Aug 2006 21:52:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.mcgees.org/wordpress/?p=131#comment-265</guid>
		<description>Thanks for posting this code!! I had a little trouble getting it to work, but then I figured out that the backslashes before the d's didn't show up in your code sample. In any case, here's the script as I got it to work, with a little extra context. I added another element to the sort, because sometimes our LC numbers have additions after the year. I've included some of these in the example. Now...will the backslashes show?

Geoff
&#62;&#62;&#62;&#62;

my @lcList = ('DK602.3.B76 1996', 'Q335.P416 1994', 'DK602.3.B76 1996a -text', 'QA76.73.P22W35 1991', 'RS75.P5', 'DA870.F64', 'DK602.3.B76 1996b -disc');

$beforeList = join ("\n", @lcList);
print "Before:\n$beforeList\n\n";

my @result = sort by_lc_number @lcList;
$afterList = join ("\n", @result);

print "\nAfter:\n$afterList\n\n";

sub by_lc_number {

	# print "A passed: $a\nB passed: $b\n";
	
	$a =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;
	@a = ($1,$2,$3,$4,$5,$6,$7,$8);
	$b =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;
	@b = ($1,$2,$3,$4,$5,$6,$7,$8);

	# $resultA = join ("::", @a);
	# $resultB = join ("::", @b);
	# print "A parsed: $resultA\nB parsed: $resultB\n";

	return
	$a[0] cmp $b[0]
	    &#124;&#124;
	$a[1] &#60;=&#62; $b[1]
	    &#124;&#124;
	$a[2] cmp $b[2]
	    &#124;&#124;
	"0.$a[3]" &#60;=&#62; "0.$b[3]"
	    &#124;&#124;
	$a[4] cmp $b[4]
	    &#124;&#124;
	"0.$a[5]" &#60;=&#62; "0.$b[5]"
	    &#124;&#124;
	$a[6] &#60;=&#62; $b[6]
	    &#124;&#124;
	$a[7] cmp $b[7]
	    ;
}</description>
		<content:encoded><![CDATA[<p>Thanks for posting this code!! I had a little trouble getting it to work, but then I figured out that the backslashes before the d&#8217;s didn&#8217;t show up in your code sample. In any case, here&#8217;s the script as I got it to work, with a little extra context. I added another element to the sort, because sometimes our LC numbers have additions after the year. I&#8217;ve included some of these in the example. Now&#8230;will the backslashes show?</p>
<p>Geoff<br />
&gt;&gt;&gt;&gt;</p>
<p>my @lcList = (&#8217;DK602.3.B76 1996&#8242;, &#8216;Q335.P416 1994&#8242;, &#8216;DK602.3.B76 1996a -text&#8217;, &#8216;QA76.73.P22W35 1991&#8242;, &#8216;RS75.P5&#8242;, &#8216;DA870.F64&#8242;, &#8216;DK602.3.B76 1996b -disc&#8217;);</p>
<p>$beforeList = join (&#8221;\n&#8221;, @lcList);<br />
print &#8220;Before:\n$beforeList\n\n&#8221;;</p>
<p>my @result = sort by_lc_number @lcList;<br />
$afterList = join (&#8221;\n&#8221;, @result);</p>
<p>print &#8220;\nAfter:\n$afterList\n\n&#8221;;</p>
<p>sub by_lc_number {</p>
<p>	# print &#8220;A passed: $a\nB passed: $b\n&#8221;;</p>
<p>	$a =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;<br />
	@a = ($1,$2,$3,$4,$5,$6,$7,$8);<br />
	$b =~ /^([A-Z]+)(\d+(?:\.\d+)?)\.?([A-Z]*)(\d*)\.?([A-Z]*)(\d*)( (?:\d{4})?)?(.*)?/;<br />
	@b = ($1,$2,$3,$4,$5,$6,$7,$8);</p>
<p>	# $resultA = join (&#8221;::&#8221;, @a);<br />
	# $resultB = join (&#8221;::&#8221;, @b);<br />
	# print &#8220;A parsed: $resultA\nB parsed: $resultB\n&#8221;;</p>
<p>	return<br />
	$a[0] cmp $b[0]<br />
	&nbsp; &nbsp; ||<br />
	$a[1] &lt;=&gt; $b[1]<br />
	&nbsp; &nbsp; ||<br />
	$a[2] cmp $b[2]<br />
	&nbsp; &nbsp; ||<br />
	&#8220;0.$a[3]&#8221; &lt;=&gt; &#8220;0.$b[3]&#8221;<br />
	&nbsp; &nbsp; ||<br />
	$a[4] cmp $b[4]<br />
	&nbsp; &nbsp; ||<br />
	&#8220;0.$a[5]&#8221; &lt;=&gt; &#8220;0.$b[5]&#8221;<br />
	&nbsp; &nbsp; ||<br />
	$a[6] &lt;=&gt; $b[6]<br />
	&nbsp; &nbsp; ||<br />
	$a[7] cmp $b[7]<br />
	&nbsp; &nbsp; ;<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
