TF-4179 Sort label list by alphabet

This commit is contained in:
dab246
2025-12-08 16:59:39 +07:00
committed by Dat H. Pham
parent 07fd854175
commit f5bddecba6
6 changed files with 24 additions and 2 deletions
@@ -39,4 +39,10 @@ extension LabelExtension on Label {
color: color ?? this.color,
);
}
int compareAlphabetically(Label otherLabel) {
return safeDisplayName
.toLowerCase()
.compareTo(otherLabel.safeDisplayName.toLowerCase());
}
}
@@ -0,0 +1,12 @@
import 'package:collection/collection.dart';
import 'package:labels/extensions/label_extension.dart';
import 'package:labels/model/label.dart';
extension ListLabelExtension on List<Label> {
void sortByAlphabetically() {
sortByCompare<Label>(
(label) => label,
(label, otherLabel) => label.compareAlphabetically(otherLabel),
);
}
}
+1
View File
@@ -11,3 +11,4 @@ export 'package:labels/method/changes/changes_label_method.dart';
export 'package:labels/method/changes/changes_label_response.dart';
export 'package:labels/extensions/label_extension.dart';
export 'package:labels/extensions/list_label_extension.dart';