<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bill Richards &#187; dom</title>
	<atom:link href="http://www.wrichards.com/blog/tag/dom/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wrichards.com/blog</link>
	<description>a developer&#039;s blog</description>
	<lastBuildDate>Tue, 20 Jul 2010 16:32:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JQuery sort()</title>
		<link>http://www.wrichards.com/blog/2009/02/jquery-sorting-elements/</link>
		<comments>http://www.wrichards.com/blog/2009/02/jquery-sorting-elements/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 16:38:43 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[innerHTML]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=48</guid>
		<description><![CDATA[Today I was trying to figure out how to sort a set of list item elements alphabetically using JQuery. Seems simple enough but after searching around I couldn&#8217;t find any ready made solution. The best I could find was JQuery Table Sort (which is a nice sorting package but not what I was looking for). [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_103" class="wp-caption alignleft" style="width: 252px"><img src="http://www.wrichards.com/blog/wp-content/uploads/2009/02/logo_jquery.png" alt="JQuery. Write less, do more" title="JQuery Logo" width="242" height="76" class="size-full wp-image-103" /><p class="wp-caption-text">JQuery. Write less, do more</p></div>Today I was trying to figure out how to sort a set of list item elements alphabetically using <a title="JQuery" href="http://jquery.com/">JQuery</a>. Seems simple enough but after searching around I couldn&#8217;t find any ready made solution. The best I could find was <a href="http://tablesorter.com/docs/">JQuery Table Sort</a> (which is a nice sorting package but not what I was looking for). After playing around for a bit, this is what I came up with:</p>
<pre name="code" class="js">jQuery.fn.sort = function() {
   return this.pushStack( [].sort.apply( this, arguments ), []);
 };

function sortAlpha(a,b){
    return a.innerHTML &gt; b.innerHTML ? 1 : -1;
};

$('ol li').sort(sortAlpha).appendTo('ol');</pre>
<p>Short and sweet. The result is a in place sort based off the innerHTML alphabetically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/jquery-sorting-elements/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
