Package: profq-sorting
ProfQ-SortingUsageYou can import the module like any other with:importprofq_sortingThen you have access to all kinds of sortingalgorithms.For example, merge sort:importprofq_sortingarr=[5,2,6,1,5]sorted_arr=profqu_sorting.merge_sort(arr)print(sorted_arr)Output: [1, 2, 5, 5, 6]There are many more algorithms which I have implemented, but here is a few that may interest you:mergesort,quicksort,radixsortandtimsort.AlgorithmsBubble Sortfromprofq_sortingimportbubble_sortBubble sort loops over the array, and for every iteration it loops over the array again, only offset by one. Then it checks every two elements and swaps them if they are out of order.Bucket Sortfromprofq_sortingimportbucket_sortMy implementation for bucket sort can only handle values between 0 and 1. Bucket sort works by creating buckets for every tenth, then it categorizes each element by multiplying it by 10 to get the index. Then it sorts each bucket usinginsertion sort. Finally it appends all the buckets together to create one array that is sorted.Counting Sortfromprofq_sortingimportcounting_sortCounting sort works by creating a table of each element in the array and thencountstheir occurrences. After that it does a cumulative sum to figure out what each elements index is. Then it loops over the array and each time an item comes up it adds it to the output array at the index calculated and then subtracts one from that index.Insertion Sortfromprofq_sortingimportinsertion_sortInsertion sort divides the array into two parts: the sorted part and the unsorted part. The first array element begins as the first item in the sorted array. Then we just loop over the unsorted part of the array andinserteach element at the right place in the sorted part.Merge Sortfromprofq_sortingimportmerge_sortMerge sort splits the array into two parts through the middle, then it does so again and again until there is only one item left in each part. Then the algoritmmergesthe items back in the correct order until it reaches the sorted array.Quick Sortfromprofq_sortingimportquick_sortQuick sort starts with a pivot, it's an item that can be chosen in multiple ways as long as it's close to the median of the array. After being chosen every item to the left of the pivot should be less than it, and every item to the right should be greater. Then just repeat for the left side and the right side and continue doing so until you have reached a sorted array.Radix Sortfromprofq_sortingimportradix_sortRadix sort depends oncounting sortto work. It basically sorts the array using the ones, then the tens and so on. It sorts these using the counting sort algorithm while keeping the order before.Selection Sortfromprofq_sortingimportselection_sortSelection sort works by looping over the array and with each iteration it will loop over the unsorted portion of the array. When it loops the first time it willselectthe minimum number in the array and put it first, then it just repeats this but without taking the sorted part into account.Shell Sortfromprofq_sortingimportshell_sortShell sort works by sorting the items in an array with gaps in between, then it keeps decreasing these gaps until they are 0.Timsortfromprofq_sortingimporttimsortThis algorithm is really complicated and it took me a couple of days to wrap my head around so don't feel the need to understand it right awayGaurav Senmade agreat seriesabout Timsort and I highly suggest you to check it out.What it does is it seperates the array into runs and sorts each run usinginsertion sort, then itmergesthe runs back into one big array using the merge function from merge sort. It's a hybrid sorting algortithm. And I know sounds really simple, but I can assure you it's not.P.S. it's named timsort becauseTiminvented it in 2002 actually.ConclusionThis is a package that I really only made so that I can say that I have made a Python package (can you believe it? I made a Python package!). And also to learn more about sorting algoritms! If you're interested in this topic there are a few Youtube channels/playlists I can recommend:GeeksForGeekshas an awesomeplaylistdetailing all kinds of sorting algoritms.Michael Sambolalso has a really coolseriesdetailing sorting algorithms in a short amount of time.It has been really fun learning about all these algorithms and I encourage you to try and implement some for yourself!