https://kotlinlang.org logo
#getting-started
Title
# getting-started
z

zt

08/31/2022, 3:34 AM
How can I get the contents of a
Path
sorted such that files/folders prefixed with a
.
are first, then alphabetically, and also so all folders come before files? I'm not really familiar with the sorting methods available to collections.
e

ephemient

08/31/2022, 3:58 AM
Copy code
path.listDirectoryEntries().sortedWith(
    compareByDescending(Path::isDirectory)
        .thenByDescending {
            it.fileName.toString().startsWith(".")
        }
        .then(naturalOrder())
    )
)
👌 1
8 Views