Skip to content

Commit

Permalink
Sort files naturally by filename; fixes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
jtooker committed Jan 25, 2017
1 parent 3659c0f commit 7e82191
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion model.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ function model(callback) {
});
}

// private -----------------------------------------------------------------
function onDirectoryLoaded() {
function compare(left, right) {
var leftName = left.fileName;
var rightName = right.fileName;
return leftName.localeCompare(rightName, undefined,
{sensitivity: "case", numeric: true});
}

m_fileInfos.sort(compare);
refresh();
}

// private -----------------------------------------------------------------
function createFileInfo(fileEntry) {
return {"fileEntry": fileEntry,
Expand All @@ -266,7 +279,7 @@ function model(callback) {
directoryReader.readEntries(
function (results) {
if (!results.length) {
refresh();
onDirectoryLoaded();
return;
}

Expand Down

0 comments on commit 7e82191

Please sign in to comment.