Change the SortFiles Method, so it works with the filesWithUniqueID Array
This commit is contained in:
parent
0e262dc2bd
commit
36192ba560
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue