Guest User

Untitled

a guest
Jan 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. val File.listFilesFolderFirst: List<File>
  2. get() {
  3. val mutableList = listFiles().toMutableList()
  4. Collections.sort(mutableList, { file1: File, file2: File ->
  5. if ((file1.isDirectory && file2.isDirectory) || (file1.isFile && file2.isFile)) {
  6. return@sort 0
  7. } else {
  8. if (file1.isDirectory) {
  9. return@sort -1
  10. } else {
  11. return@sort 1
  12. }
  13. }
  14. })
  15. return mutableList
  16. }
Add Comment
Please, Sign In to add comment