Changeset 10477
- Timestamp:
- 02/20/14 14:14:55 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Common/3.3/ListExtensions.cs
r10324 r10477 31 31 32 32 public static void StableSort<T>(this List<T> values, int index, int count) { 33 var orderedList = values.Skip(index).Take(count).OrderBy(x => x).ToList(); 34 values.Clear(); 35 values.AddRange(orderedList); 33 var orderedList = values.Skip(index).Take(count).OrderBy(x => x); 34 int i = index; 35 foreach (var e in orderedList) 36 values[i++] = e; 36 37 } 37 38 … … 41 42 42 43 public static void StableSort<T>(this List<T> values, int index, int count, IComparer<T> comparer) { 43 var orderedList = values.OrderBy(x => x, comparer).ToList(); 44 values.Clear(); 45 values.AddRange(orderedList); 44 var orderedList = values.OrderBy(x => x, comparer); 45 int i = 0; 46 foreach (var e in orderedList) 47 values[i++] = e; 46 48 } 47 49 … … 51 53 52 54 public static void StableSort<T>(this List<T> values, int index, int count, Comparison<T> comparison) { 53 var orderedList = values.OrderBy(x => x, new StableSortComparer<T>(comparison)).ToList(); 54 values.Clear(); 55 values.AddRange(orderedList); 55 var orderedList = values.OrderBy(x => x, new StableSortComparer<T>(comparison)); 56 int i = 0; 57 foreach (var e in orderedList) 58 values[i++] = e; 56 59 } 57 60
Note: See TracChangeset
for help on using the changeset viewer.