1 // Work in Progress Sort Functions
4 $.fn.sort = function(f) {
5 cur = cur.sort(function(a,b){
6 if ( typeof f == 'object' )
9 var ret = $.fn.genericSort(a,b,f);
12 b.parentNode.insertBefore( a, b );
14 a.parentNode.insertBefore( b, a );
20 $.fn.reverse = function() {
21 cur[0].parentNode.appendChild( cur[0] );
22 for ( var i = 1; cur && i < cur.length; i++ )
23 cur[i-1].parentNode.insertBefore( cur[i], cur[i-1] );
28 $.fn.genericSort = function(a,b,c) {
29 if ( typeof a == "string" || typeof b == "string" ) {
30 } else if ( c != null ) {
31 a = sibling(a.firstChild)[c].innerText;
32 b = sibling(b.firstChild)[c].innerText;
42 // Figure out if it's an American-style date
43 var re = new RegExp( "^(\d{2}).(\d{2}).(\d{2,4})$" );
47 if ( ma.length && mb.length ) {
48 a = ma.reverse().join('');
49 b = mb.reverse().join('');
52 // If it contains a number, sort on that only
53 if ( a.match(/\d/) ) {
54 var re = new RegExp("[^0-9.-]","ig");
55 a = parseFloat( a.replace( re, "" ) );
56 b = parseFloat( b.replace( re, "" ) );
59 return ( a < b ? -1 : ( a > b ? 1 : 0 ) );