Skip to content

Instantly share code, notes, and snippets.

@ljepson
Created June 19, 2013 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljepson/5818311 to your computer and use it in GitHub Desktop.
Save ljepson/5818311 to your computer and use it in GitHub Desktop.
function sort(a,b) {
var first = a.substr(0).charCodeAt();
var second = b.substr(0).charCodeAt();
if(!first || first < second || first === second) return false;
return true;
}
function check_status() {
var status_text = $('.span6:first').find('.status');
var run_again = 0;
for(var n = 0; n < status_text.length; n++) {
var sort_result = sort($(status_text[n-1]).text(),$(status_text[n]).text());
if(sort_result) {
run_again = 1;
$(status_text[n-1]).closest('tr').before($(status_text[n]).closest('tr'));
break;
}
}
if(run_again) check_status();
}
$('th:contains("Status")').on('click',check_status);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment