The TableDND plugin from Isocra should help you with the dragging and dropping, but not automatically restoring the order.
Typically when you're ordering things like this on the client side, something on the server is being updated such that the rows are already *in* the right order when you come back to the page, is there any reason you can't do that?
If you have the new order, you could attempt to move the rows into the right order by starting with your ordered list and iterating through it as an array, moving the rows around.
HOWEVER, it should be noted that it is invalid for an ID to start with or be only a numeric charcters, so all your IDs are invalid. In the following example, I will assume you change the ID to begin with alphabetic characters ('tablerow')
- var tbody = $("#table > tbody");
- $.each("16,2,27,5,11".split(","),function(i,id) {
- $("#tablerow"+id).appendTo(tbody)
- });
Since appendTo moves the elements from their original place in the DOM, each row will be moved to the bottom of the table, and at the end of the loop, the rows should be in the proper order.