Skip to content

Commit e8987ff

Browse files
committed
Use more intuitive sort order (functionally the same)
1 parent 646ae07 commit e8987ff

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

backend/FwLite/FwDataMiniLcmBridge/Api/Sorting.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public static IEnumerable<ILexEntry> ApplyRoughBestMatchOrder(this IEnumerable<I
3737
if (order.Ascending)
3838
{
3939
return projected
40-
.OrderByDescending(x => !string.IsNullOrEmpty(query) && (x.Headword?.ContainsDiacriticMatch(query!) ?? false))
41-
.ThenByDescending(x => !string.IsNullOrEmpty(query) && (x.Headword?.StartsWithDiacriticMatch(query!) ?? false))
40+
.OrderByDescending(x => !string.IsNullOrEmpty(query) && (x.Headword?.StartsWithDiacriticMatch(query!) ?? false))
41+
.ThenByDescending(x => !string.IsNullOrEmpty(query) && (x.Headword?.ContainsDiacriticMatch(query!) ?? false))
4242
.ThenBy(x => x.Headword?.Length ?? 0)
4343
.ThenBy(x => x.Headword)
4444
.ThenBy(x => x.Entry.PrimaryMorphType?.SecondaryOrder ?? stemSecondaryOrder)
@@ -49,8 +49,8 @@ public static IEnumerable<ILexEntry> ApplyRoughBestMatchOrder(this IEnumerable<I
4949
else
5050
{
5151
return projected
52-
.OrderBy(x => !string.IsNullOrEmpty(query) && (x.Headword?.ContainsDiacriticMatch(query!) ?? false))
53-
.ThenBy(x => !string.IsNullOrEmpty(query) && (x.Headword?.StartsWithDiacriticMatch(query!) ?? false))
52+
.OrderBy(x => !string.IsNullOrEmpty(query) && (x.Headword?.StartsWithDiacriticMatch(query!) ?? false))
53+
.ThenBy(x => !string.IsNullOrEmpty(query) && (x.Headword?.ContainsDiacriticMatch(query!) ?? false))
5454
.ThenByDescending(x => x.Headword?.Length ?? 0)
5555
.ThenByDescending(x => x.Headword)
5656
.ThenByDescending(x => x.Entry.PrimaryMorphType?.SecondaryOrder ?? stemSecondaryOrder)

backend/FwLite/LcmCrdt/Data/Sorting.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ from e in entries
4848
join mt in morphTypes on e.MorphType equals mt.Kind into mtGroup
4949
from mt in mtGroup.DefaultIfEmpty()
5050
orderby
51-
!string.IsNullOrEmpty(query) && SqlHelpers.ContainsIgnoreCaseAccents(e.Headword(order.WritingSystem), query!) descending,
5251
!string.IsNullOrEmpty(query) && SqlHelpers.StartsWithIgnoreCaseAccents(e.Headword(order.WritingSystem), query!) descending,
52+
!string.IsNullOrEmpty(query) && SqlHelpers.ContainsIgnoreCaseAccents(e.Headword(order.WritingSystem), query!) descending,
5353
e.Headword(order.WritingSystem).Length,
5454
e.Headword(order.WritingSystem),
5555
mt != null ? mt.SecondaryOrder : stemOrder.FirstOrDefault(),
@@ -64,8 +64,8 @@ from e in entries
6464
join mt in morphTypes on e.MorphType equals mt.Kind into mtGroup
6565
from mt in mtGroup.DefaultIfEmpty()
6666
orderby
67-
!string.IsNullOrEmpty(query) && SqlHelpers.ContainsIgnoreCaseAccents(e.Headword(order.WritingSystem), query!),
6867
!string.IsNullOrEmpty(query) && SqlHelpers.StartsWithIgnoreCaseAccents(e.Headword(order.WritingSystem), query!),
68+
!string.IsNullOrEmpty(query) && SqlHelpers.ContainsIgnoreCaseAccents(e.Headword(order.WritingSystem), query!),
6969
e.Headword(order.WritingSystem).Length descending,
7070
e.Headword(order.WritingSystem) descending,
7171
(mt != null ? mt.SecondaryOrder : stemOrder.FirstOrDefault()) descending,

0 commit comments

Comments
 (0)