Super simple jQuery sorting utility
JavaScript
Switch branches/tags
Nothing to show
Latest commit 9c27254 Feb 15, 2010 @razorjack Correcting docs markup
Permalink
Failed to load latest commit information.
README.textile
jquery.sorted.js

README.textile

Usage

Example markup:

<ul>
	<li data-id="9">one</li>
	<li data-id="8">two</li>
	<li data-id="7">three</li>
</ul>

Sorting by text value

$("ul li").sorted();

Result:

<li data-id="9">one</li>
<li data-id="7">three</li>
<li data-id="8">two</li>

Reverse sorting

$("ul li").sorted(
	{
		reversed: true
	}
);

Result:

<li data-id="8">two</li>
<li data-id="7">three</li>
<li data-id="9">one</li>

Sorting by custom value

$("ul li").sorted(
	{
		by: function(v) {
			return parseInt(v.attr('data-id'));
		}
	}
);

Result:

<li data-id="7">three</li>
<li data-id="8">two</li>
<li data-id="9">one</li>