<commit_before># InsertionSort an unsorted array
# Problem from Hackerrank

#!/bin/python

s = 6
ar = [1,4,3,5,6,2]

def insertionSort(ar):
    for i in range(1,s):  
        pivot = ar[i]    
        while i > 0 and ar[i-1] > pivot:
            ar[i] = ar[i-1]
            i -= 1            
        ar[i] = pivot
        for j in ar: print j,
        print
        
    #for k in ar: return k
    return ar


insertionSort(ar)
<commit_msg>adding another method<commit_after># InsertionSort an unsorted array
# Problem from Hackerrank

#!/bin/python

s = 6
ar = [1,4,3,5,6,2]
# Method-1
def insertionSort(ar):
    for i in range(1,s):  
        pivot = ar[i]    
        while i > 0 and ar[i-1] > pivot:
            ar[i] = ar[i-1]
            i -= 1            
        ar[i] = pivot
        for j in ar: print j,
        print
        
    #for k in ar: return k
    return ar

# Method-2
def insertionSort(ar):    
    for a0 in range(1, s):                
        pivot = ar[a0]        
        for i in reversed(range(a0)):   
            if ar[i] > pivot:
                ar[i+1] = ar[i]
                if i==0:
                    ar[i]=pivot
                #a[i], a[i+1] = a[i+1], a[i]
            elif ar[i] <= pivot:
                ar[i+1] = pivot
                break
        for j in ar: print j,
        print
       
    return ar 



insertionSort(ar)

{'fraction_non_alphanumeric': 0.11798980335032774, 'fraction_numerical': 0.025491624180626365, 'mean_word_length': 1.282392026578073, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1731737', 'n_tokens_mistral': 519, 'n_tokens_neox': 486, 'n_words': 142}