1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-11 02:10:11 +01:00

Change the SortFiles Method, so it works with the filesWithUniqueID Array

This commit is contained in:
ge64qev 2024-05-14 08:49:27 +02:00
parent 0e262dc2bd
commit 36192ba560

View File

@ -132,15 +132,15 @@ document.getElementById("sortByDateBtn").addEventListener("click", function () {
});
function sortFiles(comparator) {
// Convert FileList to array and sort
const sortedFilesArray = Array.from(document.getElementById("fileInput-input").files).sort(comparator);
// Sort the filesWithUniqueId array
const sortedFilesArray = filesWithUniqueId.sort((a, b) => comparator(a.file, b.file));
// Refresh displayed list
displayFiles(sortedFilesArray);
// Update the files property
const dataTransfer = new DataTransfer();
sortedFilesArray.forEach((file) => dataTransfer.items.add(file));
sortedFilesArray.forEach((fileObj) => dataTransfer.items.add(fileObj.file));
document.getElementById("fileInput-input").files = dataTransfer.files;
}