Sorting an array means to arrange the elements in the array in a certain order.
In C# we can sort arrays in several ways:
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Merge sort
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. The pass through the list is repeated until the list is sorted. In insertion sort, every iteration moves an element from unsorted portion to sorted portion until all the elements are sorted in the list. Selection sort is generally used for sorting files with very large records and small keys. It selects the smallest (or largest) element in the array and then removes it to place in a new list. Doing this multiple times would yield the sorted array. Quick Sort is an efficient divide-and-conquer algorithm. It divides a large list into two smaller sub-lists based on a pivot chosen, into smaller and larger elements. Quick Sort then recursively does this to the sub-lists finally producing a sorted list. Merge sort is a very efficient comparison-based sorting algorithm. It is a divide-and-conquer algorithm, which works by repeatedly dividing the array in small parts and merging them again in the sorted order.
Source: https://www.thedshandbook.com/sorting-in-arrays/