1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.UI/Extensions/BindableCollectionExtensions.cs
Robert f6090dc296 Code style - Use file scoped namespaces
Code style - Ran code cleanup
2022-08-21 11:36:15 +02:00

20 lines
675 B
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace Artemis.UI.Extensions;
public static class ObservableCollectionExtensions
{
public static void Sort<T>(this ObservableCollection<T> collection, Func<T, object> order)
{
List<T> ordered = collection.OrderBy(order).ToList();
for (int index = 0; index < ordered.Count; index++)
{
T dataBindingConditionViewModel = ordered[index];
if (collection.IndexOf(dataBindingConditionViewModel) != index)
collection.Move(collection.IndexOf(dataBindingConditionViewModel), index);
}
}
}