Skip to content

Commit

Permalink
Sort to list directories first, then sort alphabetically (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate authored and leo committed Sep 14, 2017
1 parent e815b34 commit 150c191
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/render.js
Expand Up @@ -70,6 +70,17 @@ module.exports = coroutine(function*(port, current, dir, ignoredFiles) {
})
}

// Sort to list directories first, then sort alphabetically
files = files.sort((a, b) => {
const aIsDir = a.base.endsWith('/')
const bIsDir = b.base.endsWith('/')
if (aIsDir && !bIsDir) return -1
if (bIsDir && !aIsDir) return 1
if (a.base > b.base) return 1
if (a.base < b.base) return -1
return 0
})

const render = prepareView()

const paths = []
Expand Down

0 comments on commit 150c191

Please sign in to comment.