mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Stable sorting of ResultCollection (#5850)
* Stable sorting of ResultCollection * nit fixes for resultsViewModel and ResultCollection
This commit is contained in:
committed by
GitHub
parent
ac10c988b9
commit
2d2cb22806
@@ -4,38 +4,19 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using PowerLauncher.ViewModel;
|
||||
|
||||
namespace PowerLauncher.Helper
|
||||
{
|
||||
public class ResultCollection : List<ResultViewModel>, INotifyCollectionChanged
|
||||
{
|
||||
public ResultCollection() { }
|
||||
|
||||
public ResultCollection(IEnumerable<ResultViewModel> rvm) : base(rvm) { }
|
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
|
||||
private int CompareResultViewModel(ResultViewModel c1, ResultViewModel c2)
|
||||
{
|
||||
if (c1.Result.Score > c2.Result.Score)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (c1.Result.Score == c2.Result.Score)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sort the list in descending order of score
|
||||
/// </summary>
|
||||
public new void Sort()
|
||||
{
|
||||
base.Sort(CompareResultViewModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify change in the List view items
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user