<jupyter_start><jupyter_text>**Example :-** Sorting of cards whiile playing.**Strategy :-*** Start with empty handed* Insert a card in the right position of already sorted hand* Continue till all cards are sorted<jupyter_code>arr = input("Enter space seprated values :- ")
arr = list(map(int,  arr.split()))
arr
def insertionSort(arr):
    n = len(arr)
    for j in range(1, n):
        key = arr[j]
        
        i = j-1
        while i>0 and arr[i]>key:
            arr[i+1] = arr[i]
            i -= 1
        arr[i+1] = key
        
    return arr
print('Array before sorting :- ')
print(arr)
print('------*****------')
print('Array after sorting :- ')
print(insertionSort(arr))<jupyter_output>Array before sorting :- 
[1, 5, 6, 8, 7, 2, 4, 3, 9]
------*****------
Array after sorting :- 
[1, 2, 3, 4, 5, 6, 7, 8, 9]
{'fraction_non_alphanumeric': 0.18469015795868773, 'fraction_numerical': 0.02916160388821385, 'mean_word_length': 2.5063829787234044, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '600958', 'license': 'MIT', 'n_tokens_mistral': 314, 'n_tokens_neox': 280, 'n_words': 92, 'path': 'Sorting/Insertion Sort.ipynb', 'repo_name': 'goutamdadhich/DSA_Python', 'size': '823'}