1 $.fn.sort = function(f) {
2 cur = cur.sort(function(a,b){
3 if ( typeof f == 'object' )
6 var ret = $.fn.genericSort(a,b,f);
9 b.parentNode.insertBefore( a, b );
11 a.parentNode.insertBefore( b, a );
17 $.fn.reverse = function() {
18 cur[0].parentNode.appendChild( cur[0] );
19 for ( var i = 1; cur && i < cur.length; i++ )
20 cur[i-1].parentNode.insertBefore( cur[i], cur[i-1] );
25 $.fn.genericSort = function(a,b,c) {
26 if ( typeof a == "string" || typeof b == "string" ) {
27 } else if ( c != null ) {
28 a = sibling(a.firstChild)[c].innerText;
29 b = sibling(b.firstChild)[c].innerText;
39 // Figure out if it's an American-style date
40 var re = new RegExp( "^(\d{2}).(\d{2}).(\d{2,4})$" );
44 if ( ma.length && mb.length ) {
45 a = ma.reverse().join('');
46 b = mb.reverse().join('');
49 // If it contains a number, sort on that only
50 if ( a.match(/\d/) ) {
51 var re = new RegExp("[^0-9.-]","ig");
52 a = parseFloat( a.replace( re, "" ) );
53 b = parseFloat( b.replace( re, "" ) );
56 return ( a < b ? -1 : ( a > b ? 1 : 0 ) );