使用jquery重新排序HTML表中的列

这个小提琴中有一个html表,它被创建为

Sl.No Name Dec 2013 Feb 2014 Jan 2014 Mar 2014 Nov 2013 Total
1 foo 4 7 3 5 2 21
2 bar 6 1 5 8 3 23

如何使用jquery重新排序列,以便新表中列的顺序变为Sl.No, Name, Nov 2013, Dec 2013, Jan 2014, Feb 2014, Mar 2014, Total此外,月份列由动态生成基于日期选择的服务器( FromTo日期)

 var arr = $('th').sort(function(a, b) { return new Date(a.innerHTML) > new Date(b.innerHTML); }).map(function() { return this.cellIndex }).get(); $('tr').each(function() { $(this.cells).sort(function(a, b) { a = $.inArray(a.cellIndex, arr); b = $.inArray(b.cellIndex, arr); return a > b; }).prependTo(this); }); 

http://jsfiddle.net/ZR5W7/