public void SortArray <T>(T[] array, ComparisonDel <T> comparison) where T : IComparable <T> { T temp = default(T); string arrayType = array.ToString(); if (comparison != null) { for (int i = 0; i < array.Length; i++) { for (int j = i + 1; j < array.Length; j++) { if (comparison(array[i], array[j])) { temp = array[i]; array[i] = array[j]; array[j] = temp; } Console.WriteLine($" - - - В массиве {arrayType} произошло сравнение {array[i]} и {array[j]}"); Thread.Sleep(50); } } OnSorted?.Invoke(arrayType); } }
public static T[] SortInIndividualThread <T>(T[] array, Func <T, T, int> comparer) { T[] sortedArray = null; Thread th = new Thread( () => { sortedArray = Sort(array, comparer); OnSorted?.Invoke("Sort is done."); }); th.Start(); th.Join(); return(sortedArray); }
public void AssignSortedGroups(IList <TileGroup> groups) { _groups = groups; OnSorted?.Invoke(_groups); }