So I was going through different sorting algorithms. But almost all the sorting algorithms require 2 loops to sort the array. The time complexity of Bubble sort & Insert
with python:
def sort(array): n = len(array); i = 0; mod = 0; if(len(array)<= 1): return(array) while n-1: if array[mod] > array[mod+1]: array[mod], array[mod+1] = array[mod+1], array[mod] mod+=1 if mod+1 >= n: n-=1 mod = 0 return array