I created this algorithm off the top of my head this morning. It has one loop, therefore it has a time complexity of O(n) and only stores two variable during loop so it has a space complexity O(1) time. Please correct me if the last statement is wrong. I looked online and I don't see other sorting algorithms that look like mine nor have the complexity I just mentioned. In short, did I just create a new sorting algorithm or does this sorting algorithm already exist? And if it already exists, what is its name (i.e. what type of sorting algo is it)?
def sort_algo(lst): mid = len(lst) // 2 left = 0 right = len(lst) -1 nextup = left + 1 nextdown = right - 1 while left < right or right > left: if lst[left] >= lst[mid]: lst[left], lst[mid] = lst[mid], lst[left] if lst[left] > 0: if lst[left] > lst[nextup]: lst[left], lst[nextup] = lst[nextup], lst[left] if lst[right] <= lst[mid]: lst[right], lst[mid] = lst[mid], lst[right] if lst[right] < lst[nextdown]: lst[right], lst[nextdown] = lst[nextdown], lst[right] left += 1 right -= 1 print(lst) sort_algo([7,2,1,6,8]) sort_algo([2,1,3,4,5]) sort_algo([2,1,3,9,4]) sort_algo([20,1,13,50,4])