Skip to content

Commit 3723515

Browse files
committed
refactor: call grouper.comparator in TaskGroups
1 parent 8a00df9 commit 3723515

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/Query/TaskGroups.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,10 @@ export class TaskGroups {
105105

106106
private sortTaskGroups() {
107107
const compareFn = (group1: TaskGroup, group2: TaskGroup) => {
108-
// Compare two TaskGroup objects, sorting them by the group names at each grouping level.
109-
const groupNames1 = group1.groups;
110-
const groupNames2 = group2.groups;
111-
// The containers are guaranteed to be identical sizes,
112-
// they have one value for each 'group by' line in the query.
113-
for (let i = 0; i < groupNames1.length; i++) {
114-
// For now, we only have one sort option: sort by the names of the groups.
115-
// In future, we will add control over the sorting of group headings,
116-
// which will likely involve adjusting this code to sort by applying a Comparator
117-
// to the first Task in each group.
108+
// Compare two TaskGroup objects, sorting them by first task in each group.
109+
for (let i = 0; i < this._groupers.length; i++) {
118110
const grouper = this._groupers[i];
119-
const result = groupNames1[i].localeCompare(groupNames2[i], undefined, { numeric: true });
111+
const result = grouper.comparator(group1.tasks[0], group2.tasks[0]);
120112
if (result !== 0) {
121113
return grouper.reverse ? -result : result;
122114
}

0 commit comments

Comments
 (0)