diff --git a/index.js b/index.js
index <HASH>..<HASH> 100644
--- a/index.js
+++ b/index.js
@@ -36,17 +36,18 @@ module.exports = function override() {
                 hashedPath: relPath(path.resolve(firstFile.base), file.path),
                 file: file
             });
-
-            // sort by filename length to not replace the common part(s) of several filenames
-            f.sort(function (a, b) {
-                if(a.origPath.length > b.origPath.length) return -1;
-                if(a.origPath.length < b.origPath.length) return 1;
-                return 0;
-            });
         }
         cb();
     }, function (cb) {
         var self = this;
+
+        // sort by filename length to not replace the common part(s) of several filenames
+        f.sort(function (a, b) {
+            if(a.origPath.length > b.origPath.length) return -1;
+            if(a.origPath.length < b.origPath.length) return 1;
+            return 0;
+        });
+
         f.forEach(function (_f) {
             var file = _f.file;
Sort by filename only once rather than after receiving each file.