This little script allows you to sort items in a list or any similar dom-based structure using jQuery.
$(function(){ var a = []; var o = {} var ls = $('#sortme'); var sl = document.createElement('ul'); $('#sortme').find('li').each(function(){ var t = $(this).text(); a.push(t); o[t] = this; }) a.sort(); for (var i = 0; i<a.length; i++) $(sl).append(o[a[i]]); ls.html(sl.innerHTML); })