define(["underscore"],function(e){var t,n;return n=function(t,n,r){var i,s,o;return e.isArray(n)?i=function(t){return e.map(n,function(e,n){return t[e]})}:i=n,e.isArray(r)?o=function(t){return e.map(r,function(e,n){return t[e]})}:o=r,s=e.groupBy(t,i),o&&e.each(s,function(t,n,r){return r[n]=e.sortBy(t,o)}),s},t=function(t,n,r){var i;return i=[],r=r||",",e.each(t,function(t,s){var o,u,a,f,l;return o=$("<div>").addClass("group"),a=$("<span>").addClass("group-label"),f=$("<table>").addClass("group-table"),u=$("<tr>"),l=$("<tbody>"),e.isString(s)?e.each(s.split(r),function(e){return a.append("<span class=group-key>"+$.trim(e)+"</span>")}):a.append("<span class=group-key>"+s+"</span>"),e.each(t,function(t,r){var i;return i=$("<tr>"),e.each(t,function(e,t){return n.indexOf(t)>=0?r===0:(r===0&&u.append("<th>"+t+"</th>"),i.append("<td>"+e+"</td>"))}),l.append(i)}),$("<thead>").appendTo(f).append(u),f.append(l),o.append(a,f),i.push(o)}),i},{sortedGroupBy:n,renderTable:t}})