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