Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val File.listFilesFolderFirst: List<File>
- get() {
- val mutableList = listFiles().toMutableList()
- Collections.sort(mutableList, { file1: File, file2: File ->
- if ((file1.isDirectory && file2.isDirectory) || (file1.isFile && file2.isFile)) {
- return@sort 0
- } else {
- if (file1.isDirectory) {
- return@sort -1
- } else {
- return@sort 1
- }
- }
- })
- return mutableList
- }
Add Comment
Please, Sign In to add comment