Skip to content

Commit 8763048

Browse files
authored
Sort CRDT WS's (#1910)
* Sort CRDT WS's * Also sort by WsId to ensure deterministic ordering (within each type)
1 parent 6bd027b commit 8763048

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ private void AssertWritable()
6868
public async Task<WritingSystems> GetWritingSystems()
6969
{
7070
await using var repo = await repoFactory.CreateRepoAsync();
71-
var systems = await repo.WritingSystems.ToArrayAsync();
71+
var systems = await repo.WritingSystems
72+
.OrderBy(ws => ws.Order)
73+
.ThenBy(ws => ws.WsId)
74+
.ToArrayAsync();
7275
return new WritingSystems
7376
{
74-
Analysis = systems.Where(ws => ws.Type == WritingSystemType.Analysis)
75-
.Select(w => ((WritingSystem)w)).ToArray(),
76-
Vernacular = systems.Where(ws => ws.Type == WritingSystemType.Vernacular)
77-
.Select(w => ((WritingSystem)w)).ToArray()
77+
Analysis = [.. systems.Where(ws => ws.Type == WritingSystemType.Analysis)],
78+
Vernacular = [.. systems.Where(ws => ws.Type == WritingSystemType.Vernacular)]
7879
};
7980
}
8081

0 commit comments

Comments
 (0)