message: Hoist the comparator
diff: @@ -203,6 +203,12 @@ function createWorker() {
  return { worker, cleanup };
  }
  +// comparator for sorting items in groups generated by groupItems.
  +const groupComparator = chainComparator(
  + compareBy((item) => -(item.energy?.energyCapacity || 0)),
  + compareBy((item) => (item.equipped ? 0 : 1))
  +);
  +
  /**
  * This groups items for process depending on whether any general, other or raid mods are locked as follows
  * - If there are general, other or raid mods locked it groups items by (stats, masterworked, modSlot, energyType).
  @@ -252,12 +258,7 @@ function groupItems(
  const groups = _.groupBy(items, groupingFn);
  for (const group of Object.values(groups)) {
  - group.sort(
  - chainComparator(
  - compareBy((item) => -(item.energy?.energyCapacity || 0)),
  - compareBy((item) => (item.equipped ? 0 : 1))
  - )
  - );
  + group.sort(groupComparator);
  }
  return groups;
  