mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Adding sort to DateTime extension results (#41389)
Closes #41385 Adds a sort to the DateTime extension results. <img width="1001" height="602" alt="image" src="https://github.com/user-attachments/assets/ccccae6a-c4a4-460f-a6d3-3325ecfc53da" /> <img width="992" height="606" alt="image" src="https://github.com/user-attachments/assets/b8af51bd-cbd0-4341-ac46-0fb3e97ec2ac" />
This commit is contained in:
@@ -79,16 +79,22 @@ public sealed partial class TimeDateCalculator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
List<(int Score, AvailableResult Item)> itemScores = [];
|
||||||
|
|
||||||
// Generate filtered list of results
|
// Generate filtered list of results
|
||||||
foreach (var f in availableFormats)
|
foreach (var f in availableFormats)
|
||||||
{
|
{
|
||||||
var score = f.Score(query, f.Label, f.AlternativeSearchTag);
|
var score = f.Score(query, f.Label, f.AlternativeSearchTag);
|
||||||
|
|
||||||
if (score > 0)
|
if (score > 0)
|
||||||
{
|
{
|
||||||
results.Add(f.ToListItem());
|
itemScores.Add((score, f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
results = itemScores
|
||||||
|
.OrderByDescending(s => s.Score)
|
||||||
|
.Select(s => s.Item.ToListItem())
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.Count == 0)
|
if (results.Count == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user