Created
December 10, 2012 11:04
-
-
Save BenMQ/4249996 to your computer and use it in GitHub Desktop.
table sorter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('#sort_connection').click(isort); | |
}); | |
function isort(e) { | |
console.log('sorted'); | |
var $table = $('#connection_data'); // $table = $('table') | |
var $rows = $('tr', $table).not(':eq(0)'); | |
$rows = $rows.sort(isorter); | |
$table.append($rows); | |
} | |
function isorter(a, b) { | |
var liA = $('td:eq(7) > li', a); | |
var liB = $('td:eq(7) > li', b); | |
return (!liA.length && liB.length) ? 1 :((liA.length && !liB.length)? -1 : 0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment