Like sorting with a sort, this algorithm segments the list for two parts: sorted and unheated. The algorithm sortices the second segment and inserts the current element into the correct position of the first segment.

It is assumed that the first element of the list is sorted. We go to the next element, denote it x. If x is larger than the first, leave it in its place. If it is smaller, we copy it to the second position, and set it as the first element.

Moving to other elements of the unsorted segment, we move larger elements in the sorted segment upwards, until we meet the element less than X or we will reach the end of the list. In the first case, X is placed in the right position.

The time sorting time is on average O (N²), where n is the number of list elements.

#python #Programming #Technology #DEEPLEARNING #BigDATA #Computerscience #Tech #PYTHONPROGRAMMING #PROGRAMMER