Free cookie consent management tool by TermsFeed Policy Generator

Ticket #2106: stablesort.patch

File stablesort.patch, 1.9 KB (added by abeham, 11 years ago)
  • HeuristicLab.Collections/3.3/HeuristicLab.Collections-3.3.csproj

     
    112112    <Reference Include="System.Xml" />
    113113  </ItemGroup>
    114114  <ItemGroup>
     115    <Compile Include="TempComparer.cs" />
    115116    <None Include="Plugin.cs.frame" />
    116117    <Compile Include="BidirectionalDictionary.cs" />
    117118    <Compile Include="BidirectionalLookup.cs" />
  • HeuristicLab.Collections/3.3/ObservableList.cs

     
    327327    public void Sort(Comparison<T> comparison) {
    328328      if (list.Count > 1) {
    329329        IndexedItem<T>[] oldItems = GetIndexedItems();
    330         list.Sort(comparison);
     330        list = list.OrderBy(x => x, new TempComparer<T>(comparison)).ToList();
     331        //list.Sort(comparison);
    331332        OnItemsMoved(GetIndexedItems(), oldItems);
    332333        OnPropertyChanged("Item[]");
    333334      }
  • HeuristicLab.Collections/3.3/TempComparer.cs

     
     1using System;
     2using System.Collections.Generic;
     3
     4namespace HeuristicLab.Collections {
     5  public class TempComparer<T> : IComparer<T> {
     6    public TempComparer(Comparison<T> comparison) {
     7      this.Comparison = comparison;
     8    }
     9    public int Compare(T x, T y) {
     10      return Comparison.Invoke(x, y);
     11    }
     12
     13    public Comparison<T> Comparison { get; set; }
     14  }
     15}