Skip to content

Commit 3d04191

Browse files
authored
Sort collections (#289)
1 parent d23f281 commit 3d04191

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

PerformanceCalculatorGUI/Screens/CollectionsScreen.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#nullable enable
55
using System;
6+
using System.Collections.Generic;
67
using System.IO;
78
using System.Linq;
89
using System.Security.Cryptography;
@@ -340,18 +341,25 @@ private void loadCollectionList()
340341

341342
collectionList.Clear();
342343

344+
var collections = new List<Collection>();
345+
343346
foreach (string collectionFile in Directory.EnumerateFiles(collections_directory))
344347
{
345348
var deserializedCollection = JsonConvert.DeserializeObject<Collection>(File.ReadAllText(collectionFile));
346349

347350
if (deserializedCollection != null)
348351
{
349-
var collectionButton = new CollectionButton(deserializedCollection, currentCollection);
350-
collectionList.Add(collectionButton);
351-
352-
collectionButton.OnDelete += onCollectionDelete;
352+
collections.Add(deserializedCollection);
353353
}
354354
}
355+
356+
foreach (var collection in collections.OrderBy(x => x.Name))
357+
{
358+
var collectionButton = new CollectionButton(collection, currentCollection);
359+
collectionList.Add(collectionButton);
360+
361+
collectionButton.OnDelete += onCollectionDelete;
362+
}
355363
}
356364

357365
private void onCollectionDelete(Collection collection)

0 commit comments

Comments
 (0)