diff options
author | liam4 <towerofnix@gmail.com> | 2017-06-04 16:36:55 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-06-04 16:36:55 -0300 |
commit | 40442cd9088b9680d5d62c185c7a5f5af2db2886 (patch) | |
tree | ae3a57f74dc141beaa1b8c956928dbdcd811b0fd /src | |
parent | a067d49f496d5205b02ba1358b124db5d10b3352 (diff) |
Natural sort in local crawl
Diffstat (limited to 'src')
-rwxr-xr-x | src/crawl-local.js | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/crawl-local.js b/src/crawl-local.js index cd213e0..4c510a1 100755 --- a/src/crawl-local.js +++ b/src/crawl-local.js @@ -4,6 +4,7 @@ const fs = require('fs') const path = require('path') +const naturalSort = require('node-natural-sort') const { promisify } = require('util') const readDir = promisify(fs.readdir) @@ -11,11 +12,7 @@ const stat = promisify(fs.stat) function crawl(dirPath) { return readDir(dirPath).then(items => { - items.sort((a, b) => { - const aUp = a.toUpperCase() - const bUp = b.toUpperCase() - return (aUp < bUp) ? -1 : (aUp == bUp) ? 0 : 1 - }) + items.sort(naturalSort()) return Promise.all(items.map(item => { const itemPath = path.join(dirPath, item) |