@@ -24,12 +24,24 @@ const ERR_CHUNK_INITIAL =
2424 */
2525
2626/**
27- * Compare two objects based on their ids for sorting
28- * @param {WithId } a object that contains an ID property
29- * @param {WithId } b object that contains an ID property
27+ * Compare two Modules based on their ids for sorting
28+ * @param {Module } a module
29+ * @param {Module } b module
3030 * @returns {-1|0|1 } sort value
3131 */
32- const sortById = ( a , b ) => {
32+ const sortModuleById = ( a , b ) => {
33+ if ( a . id < b . id ) return - 1 ;
34+ if ( b . id < a . id ) return 1 ;
35+ return 0 ;
36+ } ;
37+
38+ /**
39+ * Compare two ChunkGroups based on their ids for sorting
40+ * @param {ChunkGroup } a chunk group
41+ * @param {ChunkGroup } b chunk group
42+ * @returns {-1|0|1 } sort value
43+ */
44+ const sortChunkGroupById = ( a , b ) => {
3345 if ( a . id < b . id ) return - 1 ;
3446 if ( b . id < a . id ) return 1 ;
3547 return 0 ;
@@ -103,7 +115,7 @@ class Chunk {
103115 /** @private @type {SortableSet<Module> } */
104116 this . _modules = new SortableSet ( undefined , sortByIdentifier ) ;
105117 /** @private @type {SortableSet<ChunkGroup> } */
106- this . _groups = new SortableSet ( undefined , sortById ) ;
118+ this . _groups = new SortableSet ( undefined , sortChunkGroupById ) ;
107119 /** @type {Source[] } */
108120 this . files = [ ] ;
109121 /** @type {boolean } */
@@ -492,7 +504,7 @@ class Chunk {
492504 * @returns {void }
493505 */
494506 sortModules ( sortByFn ) {
495- this . _modules . sortWith ( sortByFn || sortById ) ;
507+ this . _modules . sortWith ( sortByFn || sortModuleById ) ;
496508 }
497509
498510 sortItems ( ) {
0 commit comments