Sort a table that is created using document.write() in javascript :   I have written the following code that displays a table of 4 columns on ajax success. I wish to sort this table based on the 4 columns. I tried doing it using some readymade .js files available online. but, didn't succeed. How can I achieve the requirement? 

    function Success(data)
    {
    var obj;
    obj=JSON.parse(data);
    document.write("<html><head><title>Service</title></head><body 
    bgcolor=#FFFFFB>");
    document.write("<div id=example-table>");
    document.write("<h2 align=center>Details</h2>");
    document.write("<table border-collapse=collapse, width=60%, border=1px solid 
    #ddd, align=center>");
    document.write("<tr bgcolor=#209D9D>");
    document.write("<th height=50>");
    document.write("Name");
    document.write("</th>");
    document.write("<th height=50>");
     document.write("Number1");
    document.write("</th>");
    document.write("<th height=50>");
    document.write("Number2");
    document.write("</th>");
    document.write("<th height=50>");
    document.write("Number3");
    document.write("</th>");
    document.write("</tr>");
    document.write("<br>");
    for(i=0; i<obj.length; i=i+4)
    {
    document.write("<tr bgcolor=#ffffff>");	
    document.write("<td align=center>");	
    document.write(obj[i]);
    document.write("</td>");	
    document.write("<td align=center>");	
    document.write(obj[i+1]);
    document.write("</td>");
    document.write("<td align=center>");	
    document.write(obj[i+2]);
    document.write("</td>");
    document.write("<td align=center>");	
    document.write(obj[i+3]);
    document.write("</td>");
    document.write("</tr>");	
    }

    document.write("</table>");
    document.write("</div>");
    document.write("</body></html>");
    }
    </script>