diff --git a/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt b/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt index 6954d2b..de106a7 100644 --- a/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt +++ b/trashbin/src/main/java/com/amaze/trashbin/TrashBin.kt @@ -90,9 +90,9 @@ class TrashBin constructor( filesMetadata.forEach { totalSize += it.sizeBytes } - filesMetadata.sortedByDescending { + filesMetadata.sortedBy { trashBinFile -> - trashBinFile.deleteTime + trashBinFile.deleteTime?.times(-1) } writeMetadataAndTriggerCleanup(filesMetadata, totalSize, doTriggerCleanup) return true @@ -157,9 +157,9 @@ class TrashBin constructor( filesMetadata.forEach { totalSize += it.sizeBytes } - filesMetadata.sortedByDescending { + filesMetadata.sortedBy { trashBinFile -> - trashBinFile.deleteTime + trashBinFile.deleteTime?.times(-1) } writeMetadataAndTriggerCleanup(filesMetadata, totalSize, doTriggerCleanup) return true diff --git a/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt b/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt index 857d788..3ca73d0 100644 --- a/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt +++ b/trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt @@ -52,7 +52,7 @@ data class TrashBinMetadata( fun getFilesWithDeletionCriteria(): List { var totalBytes = totalSize var numOfFiles = files.size - return files.sortedByDescending { it.deleteTime }.filter { + return files.sortedBy { it.deleteTime }.filter { file -> if (config.retentionNumOfFiles != TrashBinConfig.RETENTION_NUM_OF_FILES && numOfFiles > config.retentionNumOfFiles