public void Sorting_Sort__ReverseSequince(ISorting testClass) { int[] array = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 }; testClass.Sort(array); array.Should().Equal(1, 2, 3, 4, 5, 6, 7, 8, 9); }
// GET: Member public async Task <IActionResult> Index(string sortOrder, string searchString) { // Sets the type of person string typePerson = "Member"; // Sorting ViewData["FirstNameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "first_name" : ""; ViewData["FirstNameDescSortParm"] = String.IsNullOrEmpty(sortOrder) ? "first_name_desc" : ""; ViewData["LastNameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "last_name" : ""; ViewData["LastNameDescSortParm"] = String.IsNullOrEmpty(sortOrder) ? "last_name_desc" : ""; ViewData["EmailSortParm"] = String.IsNullOrEmpty(sortOrder) ? "email" : ""; ViewData["EmailDescSortParm"] = String.IsNullOrEmpty(sortOrder) ? "email_desc" : ""; // Search bar filter ViewData["CurrentFilter"] = searchString; var members = _sorter.Sort(_context, sortOrder, typePerson).Cast <Member>(); // Searches members with first or last name if (!String.IsNullOrEmpty(searchString)) { members = members.Where(m => m.LastName.Contains(searchString) || m.FirstName.Contains(searchString)); } return(View(await members.AsNoTracking().ToListAsync())); }
static long GetMilliSeconds(int[] array, ISorting <int> sortingAlgorithm) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); sortingAlgorithm.Sort(array); stopwatch.Stop(); long nTime = stopwatch.ElapsedTicks; stopwatch.Reset(); return(nTime); }
public Result?SortValues() { try { List <int> orderedList = sorting.Sort(randomNumbers); return(sortedNumbers.FillFromSource(randomNumbers, orderedList)); } catch (Exception e) { return(Result.Failed(e.Message)); } }
public void Sorting_Sort__RundomArray(ISorting testClass) { var random = new Random(); int[] array = new int[15]; for (int i = 0; i < array.Length; i++) { array[i] = random.Next(array.Length * 2); } testClass.Sort(array); for (int i = 0; i < array.Length - 1; i++) { Assert.True(array[i] <= array[i + 1]); } }
/// <summary> /// Sorts input in ascending order using Quick sort (Last element as Pivot) technique /// </summary> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory">Sorting algorithm factory</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> /// <returns>The ascending ordered content</returns> public static string UseQuickLastPivot(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, string input, IComparer <char> comparer = null) { return(sort.Sort(sortingAlgorithmFactory, SortingTypes.Quick_LastPivot, input, comparer)); }
/// <summary> /// Sorts input in ascending order using Quick sort (Last element as Pivot) technique /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory">Sorting algorithm factory</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UseQuickLastPivot <T>(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, T[] input, IComparer <T> comparer) { sort.Sort <T>(sortingAlgorithmFactory, SortingTypes.Quick_LastPivot, input, comparer); }
/// <summary> /// Sorts input in ascending order using Quick sort (Last element as Pivot) technique /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UseQuickLastPivot <T>(this ISorting sort, T[] input, IComparer <T> comparer) { sort.Sort <T>(SortingTypes.Quick_LastPivot, input, comparer); }
/// <summary> /// Sorts input in ascending order using Cocktail sort technique /// </summary> /// <param name="sort">ISort</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> /// <returns>The ascending ordered content</returns> public static string UseCocktail(this ISorting sort, string input, IComparer <char> comparer = null) { return(sort.Sort(SortingTypes.Cocktail, input, comparer)); }
/// <summary> /// Sorts input in ascending order using Cocktail sort technique /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory">Sorting algorithm factory</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UseCocktail <T>(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, T[] input, IComparer <T> comparer) { sort.Sort <T>(sortingAlgorithmFactory, SortingTypes.Cocktail, input, comparer); }
/// <summary> /// Sorts input in ascending order using Pancake sort technique /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory">Sorting algorithm factory</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UsePancake <T>(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, T[] input, IComparer <T> comparer) { sort.Sort <T>(sortingAlgorithmFactory, SortingTypes.Pancake, input, comparer); }
/// <summary> /// Sorts input in ascending order using Pancake sort technique /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UsePancake <T>(this ISorting sort, T[] input, IComparer <T> comparer) { sort.Sort <T>(SortingTypes.Pancake, input, comparer); }
/// <summary> /// Sorts input in ascending order using Bitonic sort technique /// This will work only if the input size is power of 2 /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory">Sorting algorithm factory</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UseBitonic <T>(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, T[] input, IComparer <T> comparer) { sort.Sort <T>(sortingAlgorithmFactory, SortingTypes.Bitonic, input, comparer); }
/// <summary> /// Sorts input in ascending order using Bitonic sort technique. /// This will work only if the input size is power of 2 /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UseBitonic <T>(this ISorting sort, T[] input, IComparer <T> comparer) { sort.Sort <T>(SortingTypes.Bitonic, input, comparer); }
/// <summary> /// Sorts input in ascending order using Comb sort technique /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="sort">ISort</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> public static void UseComb <T>(this ISorting sort, T[] input, IComparer <T> comparer) { sort.Sort <T>(SortingTypes.Comb, input, comparer); }
/// <summary> /// Sorts the specified array. /// </summary> /// <param name="array">The array.</param> public void Sort(ref int[] array) { _sorter.Sort(ref array); }
/// <summary> /// Sorts input in ascending order using Heap sort technique /// </summary> /// <param name="sort">ISort</param> /// <param name="input">input data</param> /// <param name="comparer">Comparer must returns '1' if the first element is greater than next</param> /// <returns>The ascending ordered content</returns> public static string UseHeap(this ISorting sort, string input, IComparer <char> comparer = null) { return(sort.Sort(SortingTypes.Heap, input, comparer)); }