The following code should be added to page-attachment.js in order to sort by document title:
function sortData(){ var tableData = document.getElementById('PageAttachment').getElementsByTagName('tbody').item(0); var rowData = tableData.getElementsByTagName('tr'); for(var i = 0; i < rowData.length - 1; i++){ for(var j = 0; j < rowData.length - (i + 1); j++){ var first = (rowData.item(j).getElementsByTagName('td').item(0).innerHTML.toString()); var last = (rowData.item(j+1).getElementsByTagName('td').item(0).innerHTML.toString()); if( first > last){ tableData.insertBefore(rowData.item(j+1),rowData.item(j)); } } } }
Along with this function, add the call to it:
sortData();
to pageAttachment_renderAttachmentSection(html). It should look like this:
function pageAttachment_renderAttachmentSection(html) { var e = document.getElementById('PageAttachment'); e.innerHTML = html; sortData(); }