Bienvenido al Curso

1

Introducción al curso básico de algoritmos y estructuras de datos

Introducción a los algoritmos

2

¿Qué entiende una computadora?

3

Lenguajes de programación

4

Estructuras de datos

5

¿Qué es un algoritmo?

6

Metodología para la construcción de un algoritmo

7

Variables y tipos de datos

8

User defined data types

9

Instalando Ubuntu Bash en Windows

10

Creando nuestro user defined data type

11

Abstract Data Types básicos: Lists, Stacks, Queues

12

Explicación gráfica Data Types básicos

13

Glosario de funciones para Abstract Data Types

14

Clases y objetos

15

Creando tu primera Queue: Arrays

16

Creando tu primera Queue: implementación.

17

Creando tu primera Queue: implementar la función enQueue

18

Creando tu primera Queue: implementar la función deQueue

19

Creando tu primera Queue: main code

Algoritmos de ordenamiento

20

Algoritmos de ordenamiento

21

Bubble sort

22

Bubble sort: implementación

23

Bubble sort: main code

24

Insertion sort

25

Desafío: implementa un algoritmo de ordenamiento

Recursividad

26

Recursividad

27

La función Factorial, calculando el factorial recursivamente

28

Manejo de cadenas de caracteres

29

Arte: Generando arte recursivo

Divide and conquer y programación dinámica

30

Divide and Conquer (divide y vencerás)

31

Qué es la programación dinámica (divide y vencerás v2.0)

32

MergeSort

33

Desafío: Buscar el algortimo más rápido de sort

34

Implementando QuickSort con Python

35

Implementando QuickSort con Python: main code

Algoritmos 'Greedy'

36

Qué son los Greedy Algorithm

37

Ejercicio de programación greedy

38

Ejercio de programación greedy: main code

Grafos y árboles

39

Grafos y sus aplicaciones

40

Árboles

¿Cómo comparar Algoritmos?

41

Cómo comparar algoritmos y ritmo de crecimiento

¿Qué sigue?

42

Cierre del curso y siguientes pasos

Desafío: implementa un algoritmo de ordenamiento

25/42

Lectura

¡Hola! en esta lectura quiero animarte a realizar el siguiente desafío: implementa un algoritmo de ordenamiento que sea capaz de ordenar de mayor a menor el set de datos dado, comparte tus resultados en la sección de comentarios, ¡comparte el código que utilizaste también!

...

Regístrate o inicia sesión para leer el resto del contenido.

Aportes 254

Preguntas 0

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

AQUÍ ESTAN LOS DATOS CON COMA PARA LOS QUE LO NECESITEN:
-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887
,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297
,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099
,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098
,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448
,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536
,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624
,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387
,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762
,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629
,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875
,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181
,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541
,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595

Aquí dejó la implementación del algoritmo de SelectionSort (Ordenamiento de Selección), es muy similar al BubbleSort. Los números están guardados en un archivo numbers.dat.

#include <stdio.h>
#define SIZE 300

void swap(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void selectionSort(int array[], int n) 
{
    int index, maximum;
    for(int i = 0; i < n; i++) 
    {
        index = i;
        maximum = array[i];
        for(int j = index + 1; j < n; j++)
        {
            if(array[j] > maximum) {
                index = j;
                maximum = array[j];
            }
        }
        swap(&array[index], &array[i]);
    }
}

void print_array(int array[], int n)
{
    for(int i = 0; i < n; i++)
        printf("%d ", array[i]);
    printf("\n");
}

int main() 
{
    FILE *archivo;
    int arr[SIZE];
    archivo = fopen("numbers.dat", "rb"); // abrir archivo en modo lectura

    if(archivo != NULL) // si se abrió el archivo
    {
        for(int i = 0; i < SIZE; i++)
            fscanf(archivo, "%d", &arr[i]); // leer datos del archivo
    
        fclose(archivo); // cerrar el archivo

        selectionSort(arr, SIZE);
        print_array(arr, SIZE);
    } 
    else
        printf("No se leyo el archivo");
    
    return 0;
}

Si quieres ejecutarlo:
https://repl.it/@DaneliaSanchez/selectionSort

Dejo una imagen gif de los algoritmos de ordenamiento para que agarren el que les parezca más interesante

Hola a todos, realicé el desafío utilizando el algoritmo de ordenamiento llamado Selection Sort. Utilicé el material que dejó el compañero @eagskunst en otro comentario de este desafio, el material es este.

Hay dos funciones de ordenamiento en el código:

selectionSortMinor ordena de menor a mayor.

selectionSortGreater ordena de mayor a menor.

Utilicé la segunda por las especificaciones del desafío. Aquí está el código y el resultado:


#include <stdio.h>

void swap(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void selectionSortMinor(int S[], int n)
{
    int i, j, minor;
    for (i = 0; i < n; i++)
    {
        minor = i;
        for (j = i; j < n; j++)
        {
            if (S[j] < S[minor])
                minor = j;
        }
        swap(&S[i], &S[minor]);
    }
}

void selectionSortGreater(int S[], int n)
{
    int i, j, greater;
    for (i = n - 1; i >= 0; i--)
    {
        greater = i;
        for (j = i; j >= 0; j--)
        {
            if (S[j] < S[greater])
                greater = j;
        }
        swap(&S[i], &S[greater]);
    }
}

void print(int S[], int n)
{
    int i;
    for (i = 0; i < n; i++)
        printf("%d,  ", S[i]);
    printf("\n");
}

int main(int argc, char const *argv[])
{
    int intArray[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};
    int sizeOf = sizeof(intArray) / sizeof(intArray[0]);
    selectionSortGreater(intArray, sizeOf);
    print(intArray, sizeOf);
    return 0;
}

output:

RETO CUMPLIDO con python:
NOTA: Me emocione y lo hice un poco interactivo jajaj

def myAlgorithmDESC(arr, n):

    for i in range(1, n):

        currentVal = arr[i] 
        j = i - 1

        
        while j >= 0 and (arr[j] < currentVal):

            arr[j + 1] = arr[j]
            j = j - 1

        arr[j + 1] = currentVal


    for i in range(0, n):
        print(f"{arr[i]}", end=', ')

    print("\n Fin del ordenamiento")


def myAlgorithmASC(arr, n):

    for i in range(1, n):

        currentVal = arr[i] 
        j = i - 1

        
        while j >= 0 and (arr[j] > currentVal):

            arr[j + 1] = arr[j]
            j = j - 1

        arr[j + 1] = currentVal


    for i in range(0, n):
        print(f"{arr[i]}", end=', ')

    print("\n Fin del ordenamiento")


def run():
    i = 0
    arr = []
    while True:
        number = input("Escribe un numero, para terminar escribe salir ---> ")
        if number == 'salir':
            break
           
        else:
            number = int(number)
            arr.append(number)
            i = i + 1

    print("Los valores ingresados son:")
    print(arr)
    print(f"numero de elementos: {i}")
    print("Opciones:")
    print(" 1 - Ordenarlo de menor a mayor")
    print(" 2 - Ordenarlo de mayor a menor")
    print(" 3 - Salir")
    opcion = input("---> ")

    if opcion == '1':
        myAlgorithmASC(arr, i)
    elif opcion == '2':
        myAlgorithmDESC(arr, i)
    else:
        print("Bye bye!")






if __name__ == "__main__":
    run()

Reto cumplido ordenado de mayor a menor

#include <stdio.h> 
#include <math.h> 
  
void insertionSort(int arr[], int n) 
{ 
   int currentVal,j;
   for (int i = 1; i < n; i++) 
   { 
       currentVal= arr[i]; 
       j = i-1;
  
       while (j >= 0 && arr[j] < currentVal) 
       { 
           arr[j+1] = arr[j]; 
           j = j-1; 
       } 
       arr[j+1] = currentVal; 
   } 
} 
  
void printArray(int arr[], int n) 
{ 
   int i; 
   for (i=0; i < n; i++) 
   {
   	   printf("%d , ", arr[i]); 
   	   printf("%n"); 
	}
    
} 
  

int main() 
{ 
    int arr[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906
				 ,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625
				 ,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222
				 ,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,
				 -2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,
				 -9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673
				 ,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026
				 ,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501
				 ,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662
				 ,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6,410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830
				 ,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957
				 ,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595}; 
				 
    int n = sizeof(arr)/sizeof(arr[0]); 
  
    insertionSort(arr, n); 
    printArray(arr, n); 
  
    return 0; 
}

Bubble Sort con python

def bubbleSort(arr, n):
    for i in range(0, n-1):
        for j in range(0, n-i-1):
            if arr[j] < arr[j+1]:
                temp = arr[j]
                arr[j] = arr[j+1]
                arr[j+1] = temp
            
arr_sort = []

def arrSort(arr, n):
    for i in range(n):
        arr_sort.append(arr[i])

def main():
    lista = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,
		-6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887,
		5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984,
		4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076,
		4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032,
		6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794,
		-5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791,
		-4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
		-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
		-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891,
		-2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954,
		-362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
		-5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681,
		-9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23,
		8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
		4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
		6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
		-1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
		7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
		6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
		-9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236,
		3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137,
		200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741,
		-6953, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574,
		-7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
		7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674,
		4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234,
        -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, 
        -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, 
        -4379, -8323, -6485, -4828, -5294, -2720, 595, 9995]
    div = len(lista)
    bubbleSort(lista, div)
    arrSort(lista, div)
    print(f'Arreglo ordenado: {arr_sort}')

if __name__ == "__main__":
    main() 

RETO:
La verdad no me dieron muchas ganas de escribir tantos números y escribí una función para generar números aleatorios.
La función para generar una lista de números aleatorios recibe tres parámetros(numero mínimo, numero máximo, longitud de la lista(arreglo))

import random


def quick_sort(lista):
    izquierda = []
    centro = []
    derecha = []
    if len(lista) > 1:
        pivote = lista[0]
        for i in lista:
            if i < pivote:
                izquierda.append(i)
            elif i == pivote:
                centro.append(i)
            elif i > pivote:
                derecha.append(i)
        # print(f'izq{izquierda} - cent{centro} - der{derecha}\n')
        return quick_sort(izquierda)+centro+quick_sort(derecha)
    else:
      return lista


def generar_lista_enteros(min,max,long):
    return[random.randint(min,max) for i in range(long)]


def main():
    num_riccelis = generar_lista_enteros(-1000000, 1000000,1000000)

    print(f'\nLista original:\n\n{num_riccelis}\n')
    lista_ordenada = quick_sort(num_riccelis)
    print(f'\nLista ordenada:\n\n{lista_ordenada}')
    print(f'\nLa lista contiene:\n\n{len(num_riccelis)} elementos')



if __name__ == '__main__':
    main()

NOTA: Si lo utilizas considera la longitud en la función <generar_lista_enteros> , si quieres ver el proceso de como funciona el quick sort descomenta el print dentro de la funcion quick_sort

Aqui aprendi como funciona el algoritmo Quick sort

Reto en Python con QuickSort:
Pase la lista de números a un Excel, por medio de la librería cargue el Excel, luego convertir el dataframe en una lista normal:

import pandas as pd
import numpy as np
from tkinter import filedialog as FileDialog

def quicksort(L, first, last):
    # definimos los índices y calculamos el pivote
    i = first
    j = last 
    #Seleccionamos el mejor pivote
    pivote = (L[i] + L[j]) / 2
    
    # iteramos hasta que i no sea menor que j
    while i < j:
        # iteramos mientras que el valor de L[i] sea mayo que pivote
        while L[i] > pivote:
            # Incrementamos el índice
            i+=1
        # iteramos mientras que el valor de L[j] sea menor que pivote
        while L[j] < pivote:
            # decrementamos el índice
            j-=1
        # si i es menor o igual que j significa que los índices se han cruzado
        if i <= j:
            # creamos una variable temporal para guardar el valor de L[j]
            x = L[j]
            # intercambiamos los valores de L[j] y L[i]
            L[j] = L[i]
            L[i] = x
            # incrementamos y decrementamos i y j respectivamente
            i+=1
            j-=1

    # si first es menor que j mantenemos la recursividad
    if first < j:
        L = quicksort(L, first, j)
    # si last es mayor que i mantenemos la recursividad
    if last > i:
        L = quicksort(L, i, last)

    # devolvemos la lista ordenada
    return L

def getLista(hoja1):
    lista1 = hoja1.values.tolist()
    lista2 = []
    for i,v in enumerate(lista1):
        lista2.append(v[0])

    return lista2
ruta_excel = FileDialog.askopenfilename(
    title="Abrir el archivo",
    initialdir='.',
    filetypes=(("Ficheros de excel", "*.xlsx"),)
) 
hoja = pd.read_excel(ruta_excel,sheet_name="Hoja1")         #Se guarda la lista en el dataframe hoja
lista = getLista(hoja)
print("Lista Ordenada:",quicksort(lista,0,len(lista)-1))```

-9999 -9954 -9941 -9846 -9803 -9669 -9226 -9210 -9166 -9136 -9076 -9065 -8887 -8882 -8834 -8744 -8670 -8651 -8614 -8542 -8412 -8358 -8323 -8230 -8054 -8026 -8004 -7984 -7886 -7885 -7875 -7610 -7449 -7442 -7261 -7228 -7060 -7032 -6953 -6939 -6826 -6693 -6688 -6625 -6558 -6485 -6338 -6256 -6234 -6153 -6096 -6068 -5991 -5966 -5794 -5709 -5665 -5562 -5555 -5350 -5294 -5277 -5218 -5164 -5156 -5147 -5065 -5060 -5022 -4828 -4755 -4729 -4727 -4689 -4650 -4556 -4553 -4467 -4420 -4379 -4111 -4098 -4031 -3877 -3847 -3674 -3668 -3576 -3535 -3269 -3261 -3260 -3181 -3099 -3066 -3034 -2980 -2948 -2940 -2925 -2906 -2905 -2871 -2796 -2720 -2691 -2685 -2601 -2570 -2541 -2438 -2414 -2409 -2371 -2204 -2105 -2099 -2089 -2083 -2055 -1997 -1981 -1793 -1766 -1683 -1666 -1634 -1610 -1574 -1484 -1446 -1176 -1160 -1078 -1062 -1062 -1018 -916 -796 -749 -702 -673 -501 -479 -443 -429 -369 -362 -362 -239 -238 8 23 59 200 458 537 595 676 680 766 824 946 1032 1065 1123 1175 1229 1246 1305 1455 1505 1635 1822 1936 2037 2076 2228 2325 2461 2565 2615 2649 2732 2770 2772 2926 3077 3096 3164 3229 3261 3287 3302 3352 3368 3372 3536 3577 3672 3682 3786 3870 3943 4076 4222 4297 4302 4397 4408 4408 4410 4483 4575 4624 4632 4735 4800 4926 4957 5008 5063 5073 5106 5107 5114 5219 5241 5361 5487 5517 5574 5622 5649 5650 5850 5904 6010 6148 6187 6199 6291 6356 6399 6410 6586 6637 6662 6679 6741 6796 6941 7079 7137 7177 7201 7236 7387 7452 7629 7831 7878 7889 7891 7957 7966 8208 8233 8246 8252 8459 8502 8523 8553 8578 8599 8681 8762 8780 8830 8872 8965 8987 9131 9162 9222 9254 9329 9421 9448 9497 9521 9545 9551 9622 9720 9791 9883 9885 9976

javascript

const bubbleSort = arr => {
    const l = arr.length;
    for (let i = 0; i < l; i++) {
        for (let j = 0; j < l - 1 - i; j++) {
            if (arr[j] < arr[j + 1]) {
                [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
            }
        }
    }
  return arr;
};

const arr = [-796, 3229, - 5164, - 362, 4408, 8965, - 6068, 9329, - 3034,
     - 443, - 6693, 9497, 2615, - 5966, - 9065, - 1160, 6148, 5517, 1123,
     - 8887, 5649, 3302, - 1176, - 8542, - 9166, 8, - 2906, 8987, - 2414, 
     - 7984, 4410, 8872, 5241, - 4556, 59, - 5562, - 3877, 7452, - 4467, 
      2076, 4076, 4297, - 3847, - 2055, 4483, - 1484, - 2371, 6199, - 7261,
     - 7032, 6010, 2325, - 6625, - 2601, 3870, 1822, - 5665, 9622, 9883, 
     - 5794, - 5218, 2926, 8599, - 3099, 6399, - 2570, 3943, - 2409, 5114, 
     9791, - 4420, 1065, 3077, - 1062, - 8004, 4397, 1635, 8578, - 9226, 9222, 
     - 1793, - 2691, - 5060, - 4727, - 4098, 946, - 6558, - 4111, 4575, - 2685, 
     - 4729, - 5277, 1936, 5106, - 2089, 824, 9421, - 1683, - 2083, 7891, - 2099, 
     130, - 9076, - 3535, 2565, - 2871, 9448, 7177, - 8614, - 9954, - 362, 1455, 
     - 8834, - 9846, - 8412, 1175, - 1981, - 5991, 7201, - 1997, - 5156, - 1634, 
     - 9803, 1032, 9551, - 6153, 8502, 3536, - 2980, 8681, - 9210, 4408, 8780,
     - 916, - 369, - 8651, 1246, - 702, - 5555, 23, 8208, 2037, 6941, 9545, 
     - 5147, 5063, - 8358, 2772, 8553, 9885, 4624, - 3576, 9131, 1229, - 429,
     - 479, - 673, - 7060, - 4031, 5650, 6679, 6796, 5622, - 6256, - 238, 
     - 6096, 3096, - 1610, - 2948, 6291, - 1666, 5219, 5850, 7387, - 3260, 
     3672, - 1766, - 9941, 8252, 2649, 7079, - 8026, 6356, 676, - 5065, 
     - 6338, 3287, 680, - 3269, 2770, 6637, - 8744, 9162, - 2204, - 3066, 
     - 7228, 8762, 1505, 4957, 766, - 9136, 4632, - 5022, - 9999, 5361, 2732,
     7831, - 501, - 4650, 7236, 3682, - 2438, 5574, - 8230,- 9669, - 7442, 7966,
     - 2905, 7629, 7137, 200, - 8670, - 749, 2228, 458, 7889, - 3668, - 5350, 
     - 3261, 6741, - 6953, 4800, 3372, 6662, - 1018, 8523, 3164, 3577, 9720, 
     - 6826, - 1574, - 7875, - 2796, - 1078, - 4755, 4926, 3368, 4302, 9254,
     6410, - 4689, 7878, 2461, 8233, - 6688, 5904, 4735, - 2940, 8830, 9976, 
     - 3674, 4222,- 1446, 6187- 3181, - 8882, 5487, - 6939, - 7885, 3786, 
     - 6234, - 1062, - 4553, - 5709, 8459, 5008, 3352, 6586, 537, - 7610, 
     3261, 8246, - 2105, 5107, 7957, - 7886, - 2925, - 2541, - 7449, 9521, 
     5073, - 239, - 8054, - 4379, - 8323, - 6485, - 4828, - 5294, - 2720, 595];

     const result = bubbleSort(arr);
     result;```


function swap(myArr, indexOne, indexTwo){
if( indexOne == indexTwo ){
return myArr;
}
var tmpVal = myArr[indexOne];
myArr[indexOne] = myArr[indexTwo];
myArr[indexTwo] = tmpVal;
return myArr;
}

function selectionSort(myArr) {
var size = myArr.length;
for (var slot = 0; slot < size -1; slot++) { // outer loop
var smallest = slot;
for (var check = slot + 1; check < size; check++) { // inner loop
if (myArr[check] > myArr[smallest]) {
smallest = check;
}
}
swap( myArr, smallest, slot );
}
return myArr;
}

var myArr = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034,
-443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123,
-8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414,
-7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467,
2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261,
-7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883,
-5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114,
9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099,
130, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954, -362, 1455,
-8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -5156, -1634,
-9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780,
-916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545,
-5147, 5063, -8358, 2772, 8553, 9885, 4624, -3576, 9131, 1229, -429,
-479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238,
-6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260,
3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065,
-6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066,
-7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732,
7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966,
-2905, 7629, 7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350,
-3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720,
-6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254,
6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976,
-3674, 4222, -1446, 6187 - 3181, -8882, 5487, -6939, -7885, 3786,
-6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610,
3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521,
5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595];
console.log(selectionSort(myArr));

public class Orden {

    public void orden(int[]values){
        int aux=0;
        for (int i = 0; i <values.length ; i++) {
            for (int j=i+1; j<values.length; j++){
                if(values[i] > values[j]){
                    aux = values[j];
                    values[j] = values[i];
                    values[i] = aux;
                }
            }
        }
    }

    public void printValues(int []values){
        for (int i = 0; i < values.length ; i++) {
            System.out.println(values[i]);
        }

    }
}

********************************

public class Main {

    public static void main(String[] args) {
        int []values = {-796,3229,-5164 ,-362 ,4408 ,8965 ,-6068 ,9329 ,-3034 ,-443 ,-6693 ,9497 ,2615 ,-5966 ,-9065 ,-1160 ,6148 ,5517 ,1123 ,-8887 ,5649 ,3302 ,-1176 ,-8542 ,-9166 ,8 ,-2906 ,8987 ,-2414 ,-7984 ,4410 ,8872 ,5241 ,-4556 ,59 ,-5562 ,-3877 ,7452 ,-4467 ,2076 ,4076 ,4297 ,-3847 ,-2055 ,4483 ,-1484 ,-2371 ,6199 ,-7261 ,-7032 ,6010 ,2325 ,-6625 ,-2601 ,3870 ,1822 ,-5665 ,9622 ,9883 ,-5794 ,-5218 ,2926 ,8599 ,-3099 ,6399 ,-2570 ,3943 ,-2409 ,5114 ,9791 ,-4420 ,1065 ,3077 ,-1062 ,-8004 ,4397 ,1635 ,8578 ,-9226 ,9222 ,-1793 ,-2691 ,-5060 ,-4727 ,-4098 ,946 ,-6558 ,-4111 ,4575 ,-2685 ,-4729 ,-5277 ,1936 ,5106 ,-2089 ,824 ,9421 ,-1683 ,-2083 ,7891 ,-2099 ,1305 ,-9076 ,-3535 ,2565 ,-2871 ,9448 ,7177 ,-8614 ,-9954 ,-362 ,1455 ,-8834 ,-9846 ,-8412 ,1175 ,-1981 ,-5991 ,7201 ,-1997 ,-5156 ,-1634 ,-9803 ,1032 ,9551 ,-6153 ,8502 ,3536 ,-2980 ,8681 ,-9210 ,4408 ,8780 ,-916 ,-369 ,-8651 ,1246 ,-702 ,-5555 ,23 ,8208 ,2037 ,6941 ,9545 ,-5147 ,5063 ,-8358 ,2772 ,8553 ,9885 ,4624 ,-3576 ,9131 ,1229 ,-429 ,-479 ,-673 ,-7060 ,-4031 ,5650 ,6679 ,6796 ,5622 ,-6256 ,-238 ,-6096 ,3096 ,-1610 ,-2948 ,6291 ,-1666 ,5219 ,5850 ,7387 ,-3260 ,3672 ,-1766 ,-9941 ,8252 ,2649 ,7079 ,-8026 ,6356 ,676 ,-5065 ,-6338 ,3287 ,680 ,-3269 ,2770 ,6637 ,-8744 ,9162 ,-2204 ,-3066 ,-7228 ,8762 ,1505 ,4957 ,766 ,-9136 ,4632 ,-5022 ,-9999 ,5361 ,2732 ,7831 ,-501 ,-4650 ,7236 ,3682 ,-2438 ,5574 ,-8230 ,-9669 ,-7442 ,7966 ,-2905 ,7629 ,7137 ,200 ,-8670 ,-749 ,2228 ,458 ,7889 ,-3668 ,-5350 ,-3261 ,6741 ,-6953 ,4800 ,3372 ,6662 ,-1018 ,8523 ,3164 ,3577 ,9720 ,-6826 ,-1574 ,-7875 ,-2796 ,-1078 ,-4755 ,4926 ,3368 ,4302 ,9254 ,6410 ,-4689 ,7878 ,2461 ,8233 ,-6688 ,5904 ,4735 ,-2940 ,8830 ,9976 ,-3674 ,4222 ,-1446 ,6187 ,-3181 ,-8882 ,5487 ,-6939 ,-7885 ,3786 ,-6234 ,-1062 ,-4553 ,-5709 ,8459 ,5008 ,3352 ,6586 ,537 ,-7610 ,3261 ,8246 ,-2105 ,5107 ,7957 ,-7886 ,-2925 ,-2541 ,-7449-796,3229,-5164,-362 ,4408 ,8965 ,-6068 ,9329 ,-3034 ,-443 ,-6693 ,9497 ,2615 ,-5966 ,-9065 ,-1160 ,6148 ,5517 ,1123 ,-8887 ,5649 ,3302 ,-1176 ,-8542 ,-9166 ,8 ,-2906 ,8987 ,-2414 ,-7984 ,4410 ,8872 ,5241 ,-4556 ,59 ,-5562 ,-3877 ,7452 ,-4467 ,2076 ,4076 ,4297 ,-3847 ,-2055 ,4483 ,-1484 ,-2371 ,6199 ,-7261 ,-7032 ,6010 ,2325 ,-6625 ,-2601 ,3870 ,1822 ,-5665 ,9622 ,9883 ,-5794 ,-5218 ,2926 ,8599 ,-3099 ,6399 ,-2570 ,3943 ,-2409 ,5114 ,9791 ,-4420 ,1065 ,3077 ,-1062 ,-8004 ,4397 ,1635 ,8578 ,-9226 ,9222 ,-1793 ,-2691 ,-5060 ,-4727 ,-4098 ,946 ,-6558 ,-4111 ,4575 ,-2685 ,-4729 ,-5277 ,1936 ,5106 ,-2089 ,824 ,9421 ,-1683 ,-2083 ,7891 ,-2099 ,1305 ,-9076 ,-3535 ,2565 ,-2871 ,9448 ,7177 ,-8614 ,-9954 ,-362 ,1455 ,-8834 ,-9846 ,-8412 ,1175 ,-1981 ,-5991 ,7201 ,-1997 ,-5156 ,-1634 ,-9803 ,1032 ,9551 ,-6153 ,8502 ,3536 ,-2980 ,8681 ,-9210 ,4408 ,8780 ,-916 ,-369 ,-8651 ,1246 ,-702 ,-5555 ,23 ,8208 ,2037 ,6941 ,9545 ,-5147 ,5063 ,-8358 ,2772 ,8553 ,9885 ,4624 ,-3576 ,9131 ,1229 ,-429 ,-479 ,-673 ,-7060 ,-4031 ,5650 ,6679 ,6796 ,5622 ,-6256 ,-238 ,-6096 ,3096 ,-1610 ,-2948 ,6291 ,-1666 ,5219 ,5850 ,7387 ,-3260 ,3672 ,-1766 ,-9941 ,8252 ,2649 ,7079 ,-8026 ,6356 ,676 ,-5065 ,-6338 ,3287 ,680 ,-3269 ,2770 ,6637 ,-8744 ,9162 ,-2204 ,-3066 ,-7228 ,8762 ,1505 ,4957 ,766 ,-9136 ,4632 ,-5022 ,-9999 ,5361 ,2732 ,7831 ,-501 ,-4650 ,7236 ,3682 ,-2438 ,5574 ,-8230 ,-9669 ,-7442 ,7966 ,-2905 ,7629 ,7137 ,200 ,-8670 ,-749 ,2228 ,458 ,7889 ,-3668 ,-5350 ,-3261 ,6741 ,-6953 ,4800 ,3372 ,6662 ,-1018 ,8523 ,3164 ,3577 ,9720 ,-6826 ,-1574 ,-7875 ,-2796 ,-1078 ,-4755 ,4926 ,3368 ,4302 ,9254 ,6410 ,-4689 ,7878 ,2461 ,8233 ,-6688 ,5904 ,4735 ,-2940 ,8830 ,9976 ,-3674 ,4222 ,-1446 ,6187 ,-3181 ,-8882 ,5487 ,-6939 ,-7885 ,3786 ,-6234 ,-1062 ,-4553 ,-5709 ,8459 ,5008 ,3352 ,6586 ,537 ,-7610 ,3261 ,8246 ,-2105 ,5107 ,7957 ,-7886 ,-2925 ,-2541 ,-7449 ,9521 ,5073 ,-239 ,-8054 ,-4379 ,-8323 ,-6485 ,-4828 ,-5294 ,-2720 ,595 };

        Orden orden1 = new Orden();
        orden1.orden(values);
        System.out.println("elementos ordenandos");
        orden1.printValues(values);
    }
}

Script en python corriendo tres tipos de algoritmos y comparando su tiempo de ejecución. Lo siento Celis, me dio flojera tomar tu array.

import timeit
from random import randint

def bubble_sort(arr):
	for i in range(len(arr)):
		for j in range(0, len(arr) - i - 1):
			if arr[j] > arr[j + 1]:
				arr[j], arr[j + 1] = arr[j + 1], arr[j]

def insertion_sort(arr):
	for i in range(1, len(arr)):
		currentVal = arr[i]
		j = i - 1
		while j >= 0 and arr[j] > currentVal:
			arr[j + 1] = arr[j]
			j -= 1
		arr[j + 1] = currentVal

def make_random_array():
	return [randint(-100, 100) for i in range(20)]

test_array1 = make_random_array()
test_array2 = make_random_array()
test_array3 = make_random_array()


def compare_functions():

	setup_code1 = """
from __main__ import bubble_sort
from __main__ import test_array1
	""" 

	setup_code2 = """
from __main__ import insertion_sort
from __main__ import test_array2
	"""

	setup_code3 = """
from __main__ import test_array3
	"""

	code1 = "bubble_sort(test_array1)"
	code2 = "insertion_sort(test_array2)"
	code3 = "sorted(test_array3)"

	time1 = timeit.repeat(stmt=code1, setup=setup_code1, number=1000, repeat=5)
	time2 = timeit.repeat(stmt=code2, setup=setup_code2, number=1000, repeat=5)
	time3 = timeit.repeat(stmt=code3, setup=setup_code3, number=1000, repeat=5)

	print(f"Tiempo para terminar bubble sort es {min(time1)} segundos.")
	print(f"Tiempo para terminar insertion sort es {min(time2)} segundos.")
	print(f"Tiempo para terminar sorted es {min(time3)} segundos.")

def run_sorts():
	test_array1 = make_random_array()
	test_array2 = make_random_array()
	test_array3 = make_random_array()
	print(f"Vector antes de bubble sort: {test_array1}")
	bubble_sort(test_array1)
	print(f"Vector después de bubble sort: {test_array1}")
	print("-"*50)
	print(f"Vector antes de insertion sort: {test_array2}")
	insertion_sort(test_array2)
	print(f"Vector después de insertion sort: {test_array2}")
	print("-"*50)
	print(f"Vector antes de sorted: {test_array3}")
	print(f"Vector después de sorted: {sorted(test_array3)}")

if __name__ == "__main__":
	compare_functions()
	run_sorts()


Creé una clase que carga en un array todo el set de datos que nos dió el profesor Ricardo. También tiene un método para imprimirlo y otro que devuelve la longitud de este. Así se podría evitar ingresar los datos en un array manualmente.

#ifndef NUMBERSET_H
#define NUMBERSET_H
#define ITEMS 300
#include <fstream>
#include <iostream>

class DataSet{
    private:
        void loadSet();
    public:
        DataSet();
        void print();
        int getN();
        int numberSet[ITEMS];
    
};

DataSet::DataSet(){
    loadSet();
}

void DataSet::loadSet(){
    std::string line;
    std::ifstream file("dataSet.txt");

    if(file.is_open()){
        int i = 0;
        while(getline(file, line)){
            numberSet[i] = std::stoi(line);
            i++;
        }
    }
}

void DataSet::print(){
    for(int i = 0; i < ITEMS; i++)
        std::cout << numberSet[i] << " ";
}

int DataSet::getN(){
    return ITEMS;
}

#endif ```

Mi reto utilizando Insertion Sort en JS

const insertionSort = (arr) => {
    let n = arr.length;
        for (let i = 1; i < n; i++) {
            let a = arr[i];
            let j = i-1; 
            while ((j > -1) && (a < arr[j])) {
                arr[j+1] = arr[j];
                j--;
            }
            arr[j+1] = a;
        }
    return arr;
}

console.log(insertionSort([-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034,
    -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123,
    -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414,
    -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467,
    2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261,
    -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883,
    -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114,
    9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
    9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575,
    -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083,
    7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614,
    -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201,
    -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980,
    8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555,
    23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
    4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
    6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
    -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
    7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
    6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
    -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 
    3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 
    200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, 
    -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, 
    -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410,
    -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, 
    -3674, 4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786,
    -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 
    3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 
    5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595]))
#include <stdio.h>



void cambio(int *n1, int *n2)
{
    int aux = *n1;
    *n1 = *n2;
    *n2 = aux;
}

int main(int argc, char const *argv[])
{
    int array[]={-796, 3229,
-5164,
-362,
4408,
8965,
-6068,
9329,
-3034,
-443,
-6693,
9497,
2615,
-5966,
-9065,
-1160,
6148,
5517,
1123,
-8887,
5649,
3302,
-1176,
-8542,
-9166,
8,
-2906,
8987,
-2414,
-7984,
4410,
8872,
5241,
-4556,
59,
-5562,
-3877,
7452,
-4467,
2076,
4076,
4297,
-3847,
-2055,
4483,
-1484,
-2371,
6199,
-7261,
-7032,
6010,
2325,
-6625,
-2601,
3870,
1822,
-5665,
9622,
9883,
-5794,
-5218,
2926,
8599,
-3099,
6399,
-2570,
3943,
-2409,
5114,
9791,
-4420,
1065,
3077,
-1062,
-8004,
4397,
1635,
8578,
-9226,
9222,
-1793,
-2691,
-5060,
-4727,
-4098,
946,
-6558,
-4111,
4575,
-2685,
-4729,
-5277,
1936,
5106,
-2089,
824,
9421,
-1683,
-2083,
7891,
-2099,
1305,
-9076,
-3535,
2565,
-2871,
9448,
7177,
-8614,
-9954,
-362,
1455,
-8834,
-9846,
-8412,
1175,
-1981,
-5991,
7201,
-1997,
-5156,
-1634,
-9803,
1032,
9551,
-6153,
8502,
3536,
-2980,
8681,
-9210,
4408,
8780,
-916,
-369,
-8651,
1246,
-702,
-5555,
23,
8208,
2037,
6941,
9545,
-5147,
5063,
-8358,
2772,
8553,
9885,
4624,
-3576,
9131,
1229,
-429,
-479,
-673,
-7060,
-4031,
5650,
6679,
6796,
5622,
-6256,
-238,
-6096,
3096,
-1610,
-2948,
6291,
-1666,
5219,
5850,
7387,
-3260,
3672,
-1766,
-9941,
8252,
2649,
7079,
-8026,
6356,
676,
-5065,
-6338,
3287,
680,
-3269,
2770,
6637,
-8744,
9162,
-2204,
-3066,
-7228,
8762,
1505,
4957,
766,
-9136,
4632,
-5022,
-9999,
5361,
2732,
7831,
-501,
-4650,
7236,
3682,
-2438,
5574,
-8230,
-9669,
-7442,
7966,
-2905,
7629,
7137,
200,
-8670,
-749,
2228,
458,
7889,
-3668,
-5350,
-3261,
6741,
-6953,
4800,
3372,
6662,
-1018,
8523,
3164,
3577,
9720,
-6826,
-1574,
-7875,
-2796,
-1078,
-4755,
4926,
3368,
4302,
9254,
6410,
-4689,
7878,
2461,
8233,
-6688,
5904,
4735,
-2940,
8830,
9976,
-3674,
4222,
-1446,
6187,
-3181,
-8882,
5487,
-6939,
-7885,
3786,
-6234,
-1062,
-4553,
-5709,
8459,
5008,
3352,
6586,
537,
-7610,
3261,
8246,
-2105,
5107,
7957,
-7886,
-2925,
-2541,
-7449,
9521,
5073,
-239,
-8054,
-4379,
-8323,
-6485,
-4828,
-5294,
-2720,
595};
    int i, j;
    int n = sizeof(array) / sizeof(array[0]);
    for(i = 0; i < n; i++)
    {
        for(j = i; j < n; j++)
        {

            if(array[i]>array[j])
            {
            cambio(&array[i], &array[j]);
            }
        }
        printf("%i, ", array[i]);
    }
printf("\n");



    return 0;
}

hice un insertion sort en js:

![](/home/juan/Imágenes/Captura de pantalla -2020-12-06 01-27-36.png)

js:

<var numbersToOrder = document.getElementById("numbersToOrder");
var order = document.getElementById("order");
var result =  document.getElementById("result");

order.addEventListener("click", function() { 

    var numeros = [];
    var inputString = numbersToOrder.value;
    numeros = inputString.split(",");
    parseIntArray(numeros);
    insertionSort(numeros);
    result.innerHTML = numeros ;

});

function parseIntArray(inputArr) {
    let n = inputArr.length;
        for (let i = 1; i < n; i++) {
            inputArr[i] = parseInt(inputArr[i]);
        }
    return inputArr;
}

function insertionSort(inputArr) {
    let n = inputArr.length;
        for (let i = 1; i < n; i++) {
            // Choosing the first element in our unsorted subarray
            let current = inputArr[i];
            // The last element of our sorted subarray
            let j = i-1; 
            while ((j > -1) && (current < inputArr[j])) {
                inputArr[j+1] = inputArr[j];
                j--;
            }
            inputArr[j+1] = current;
        }
    return inputArr;
}>

html:

<<!DOCTYPE html>
<html lang="es">
<head>
<title>Titulo de la web| Menos de 55 caracteres</title>
<meta charset="utf-8" />
<meta name="description" content="Debe contener las palabras clave, tratar de atraer clicks y de longitud entre 150 y 160 caracteres">

</head>
 
<body>
   
    <header>
       <h1>Mi sitio web</h1>
       <p>Mi sitio web creado en html5</p>
       
    </header>
    <section>
        <p><label>ingrese los numeros a ordenar separados por coma:</label></p>

        <p><input type="text" id="numbersToOrder" name="name" size="30"></p>
        
        <p><button id="order" type="button">Order</button></p>
        
        <p><label id="result"></label></p>

    </section>

</body>
<script type="text/javascript" src="algoritmo.js"></script>
</html>>

Hice un código que permite ingresar un archivo de texto y así ordenar los números que contenga, da mucha flojera ingresar el arreglo completo :"v, les dejo el código, solo tienen que tener un archivo txt y listo 😃 ❤️

#include <stdio.h>
#include <stdlib.h>
#define MAX 301

void cambiarPor(int *n1,int *n2);
void bubblesort(int vector_entrada[],int n);
int print(int vector_entrada[],int n);

int main(int argc, char const *argv[]) {


  FILE * fp = fopen( "numeros.txt", "r");

  char buf[MAX];
  int i = 0,numerosEnteros[MAX];

  while(i<300)
  {
  fgets(buf, MAX,fp );
  printf("numero is [ %d]: %s\n",i+1, buf);
  numerosEnteros[i] = atoi(buf);
  i++;
  }
  fclose(fp);

  int tamaño = sizeof(numerosEnteros)/sizeof(int);
  bubblesort(numerosEnteros,tamaño);
  print(numerosEnteros,tamaño);
  printf("\n");
  return 0;
}

void cambiarPor(int *n1,int *n2)
{
  int temp = *n1;
  *n1 = *n2;
  *n2 = temp;
}
void bubblesort(int vector_entrada[],int n)
{
  int i ,j;
  for( i = 0; i < n-1 ; i++)
  {
    for(j = 0; j < n-i-1 ; j++)
    {
      if(vector_entrada[j] < vector_entrada[j+1])
      {
          cambiarPor(&vector_entrada[j], &vector_entrada[j+1]);
      }
    }
  }
}

int print(int vector_entrada[],int n)
{
  int i;
  for( i = 0; i < n-1; i++)
  {
    printf("%d,", vector_entrada[i]);
  }
  printf("Fin del ordenamiento\n");
}




Aquí tengo una solución sencilla usando Javascript

Reto completado:

#include<stdio.h>
void cambiar_pos(int *n1, int *n2){
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}
void bubbleSort(int array[], int n){
    int i;
    int j;
    for(i = 0; i < n-1; i++){
        for(j = 0; j < n-i-1; j++){
            if(array[j]>array[j+1]){
                cambiar_pos(&array[j], &array[j+1]);
            }
        }
    }
}
int printe(int array[], int n){
    int i;
    for (i = 0; i < n; i++)
        printf("%d ,", array[i]);
    printf("\n Fin del ordenamiento Acsendente \n");
}
int printa(int array[], int n){
    int i;
    for (i = 299; i >= 0; i--)
        printf("%d ,", array[i]);
    printf("\n Fin orden Descendente");
}
main(int argc, char const *argv[])
{
    int array[]= {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,
		-6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887,
		5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984,
		4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076,
		4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032,
		6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794,
		-5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791,
		-4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
		-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
		-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891,
		-2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954,
		-362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
		-5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681,
		-9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23,
		8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
		4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
		6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
		-1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
		7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
		6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
		-9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236,
		3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137,
		200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741,
		-6953, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574,
		-7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
		7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674,
		4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234,
		-1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261,
		8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073,
		-239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595, 9995};
    int n = sizeof(array)/sizeof(array[0]);
    bubbleSort(array, n);
    printe(array, n);
    printa(array, n);
    printf("\n");
    return 0;
}

Utilicé el algoritmo de QuickSort

def quickSort(alist):
  quickSortHelper(alist,0,len(alist)-1)

def quickSortHelper(alist,first,last):
  if first<last:
    splitpoint = partition(alist, first, last)
    quickSortHelper(alist, first, splitpoint-1)
    quickSortHelper(alist, splitpoint+1, last)

def partition(alist, first, last):
  pivotvalue = alist[first]
  leftmark = first + 1
  rightmark = last
  done = False
  
  while not done:
    while leftmark <= rightmark and alist[leftmark]<=pivotvalue:
      leftmark = leftmark + 1
    while leftmark <= rightmark and alist[rightmark]>=pivotvalue:
      rightmark=rightmark - 1
    if rightmark<leftmark:
      done = True
    else:
      temp = alist[leftmark]
      alist[leftmark] = alist[rightmark]
      alist[rightmark] = temp
  temp = alist[first]
  alist[first] = alist[rightmark]
  alist[rightmark] = temp

  return rightmark

alist = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,
		-6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887,
		5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984,
		4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076,
		4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032,
		6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794,
		-5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791,
		-4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
		-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
		-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891,
		-2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954,
		-362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
		-5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681,
		-9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23,
		8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
		4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
		6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
		-1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
		7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
		6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
		-9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236,
		3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137,
		200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741,
		-6953, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574,
		-7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
		7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674,
		4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234,-1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595, 9995]
quickSort(alist)
print(alist)```

Logrado, utilice el insertion sort de la clase anterior.


#include <stdio.h>



//Imprimir elementos
void showElements(int cant, int array[]){
	
	int i;
	
	for(i=0;i<cant;i++){
		printf("%d, ", array[i]);
	}
	
	printf("\n");
}


//Ordenamiento de los elementos
void orderElements(int cant, int array[]){
	
	int i, pos, aux;
	
	for(i=0;i<cant;i++){
		
		pos = i;
		aux = array[i];		
		
		while((pos>0) && (array[pos-1] > aux)){
			array[pos] = array[pos-1];
			pos--;
		}
		
		array[pos] = aux;
	}
}


//Funcion principal MAIN

int main(){
	
	int n;
	int myArray[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,
					-5966,-9065,-1160,6148,5517,1123,8887,5649,3302,-1176,-8542,-9166,8,-2906,
					8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,
					4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,
					1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,3943,-2409,5114,9791,-4420,
					1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558
					,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076
					,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991
					,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780
					,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553
					,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238
					,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649
					,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228
					,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438
					,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350
					,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755
					,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222
					,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537
					,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323
					,-6485,-4828,-5294,-2720,595};
	n = sizeof(myArray) / sizeof(myArray[0]);					
	
	showElements(n, myArray);
	
	orderElements(n, myArray);
	
	showElements(n, myArray);
	
	
	return 0;
}

Me dio flojera hacer el array por lo tanto sólo hice la función y funciona super:

#include <stdio.h>
#include <math.h>

// Función de insertion Sort Mayor a menor
void insertionSort2(int arr[], int n) {
    int i, currentVal, j;
    for(i = 1; i < n; i++) {
        currentVal = arr[i];
        j = i - 1;
        while (j >= 0 && arr[j] < currentVal) {
            arr[j + 1] = arr[j];
            j = j - 1;
        }
        arr[j + 1] = currentVal;
    }
}

// función auxiliar para imprimir un arrary de tamaño n
int printArr(int arrIn[], int n) {
    for(int i = 0; i < n; i++){
        if(i == n - 1) {
            printf("%d", arrIn[i]);
        } else {
            printf("%d, ", arrIn[i]);
        }
    }
    printf("\nFin del ordenamiento\n");
}

// Driver program to test insertion sort
int main() {
    int arr[] = {6, 4, 3, 11, 10};
    int n = sizeof(arr) / sizeof(arr[0])
    insertionSort2(arr, n);
    printArr(arr, n);
    return 0;
}

Python


def buuble_sort(numbers):
    not_serted = True
    while not_serted:
        #sort
        for idx in range(len(numbers)-1):
            if numbers[idx] > numbers[idx+1]:
                numbers.insert(idx,numbers.pop(idx+1))

        #check if sorted
        for idx in range(len(numbers)-1):
            if numbers[idx] > numbers[idx+1]:
                break
            if idx == len(numbers)-2:
                print(numbers)
                not_serted = False



if __name__ == "__main__":
    buuble_sort(numbers)

Utilicé el algoritmo de InsertionSort en C y lo escribí también en Python. Les dejo ambos códigos:

Código en C

#include <stdio.h>
#include <math.h>

void insertionSort(int arr[], int n)
{
	int i, currentVal, j; 
	for(i = 1; i < n; i++)
	{
		currentVal = arr[i];
		j = i -1;

		while(j >= 0 && arr[j] > currentVal)
		{
			arr[j + 1] = arr[j];
			j = j - 1;
		}

		arr[j + 1] = currentVal;
	}
}

void printArray(int arr[], int n)
{
	int i;
	for(i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
}

int main()
{
	int arr[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,-6693,
  9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542,
  -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452,
  -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 
  2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099,6399,
  -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
  9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277,
  1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871,
  9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
  -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916,
  -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553,
  9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256,
  -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941,
  8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162,
  -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501,
  -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670,
  -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164,
  3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
  7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882,
  5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459,5008, 3352, 6586, 537, -7610, 3261,
  8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323,
  -6485, -4828, -5294, -2720, 595};
	int n = sizeof(arr) / sizeof(arr[0]);

	insertionSort(arr, n);
	printArray(arr, n);

	return 0;
}

Código en Python

def insertionSort(array, n):

	currentValue = 0
	for i in range(n):
		
		currentValue = array[i]
		j = i - 1
		
		while j >= 0 and array[j] < currentValue:
			array[j + 1] = array[j]
			j = j - 1

		array[j + 1] = currentValue

def printArray(array, n):
	for i in range(n):
		print(f"{array[i]} ")


def main():

	array = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,-6693,
  9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542,
  -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452,
  -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 
  2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099,6399,
  -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
  9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277,
  1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871,
  9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
  -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916,
  -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553,
  9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256,
  -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941,
  8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162,
  -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501,
  -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670,
  -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164,
  3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
  7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882,
  5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459,5008, 3352, 6586, 537, -7610, 3261,
  8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323,
  -6485, -4828, -5294, -2720, 595]
	n = len(array)
	insertionSort(array, n)
	printArray(array, n)

if __name__ == '__main__':
	main()

Es una combinación de SelectionSort con búsqueda binaria en python

import math

def datos():
    num = []
    with open('numeros.txt', 'r') as t:
        for line in t:
            num.append(int(line))

    return num


def run():
    num = datos()
    print(num)
    orden = 0

    for i in range(1, len(num)):
        bajo = 0
        alto = orden
        c = math.floor((bajo + alto) / 2)

        while True:
            if num[i] < num[0] or num[i] > num[orden]:
                if num[i] < num[0]:
                    num.insert(0, num[i])
                    del num[i + 1]
                orden += 1
                break

            if num[i] >= num[c]:
                bajo = c
            else:
                alto = c
            c = math.floor((bajo + alto) / 2)

            if alto - bajo == 1:
                num.insert(alto, num[i])
                del num[i + 1]
                orden += 1
                break
    print(num)


if __name__ == '__main__':
    run()

Decidí aplicar ambos algoritmos y contar la cantidad de iteraciones, para ello tuve que crear dos arreglos con la misma información, esto con el objetivo de ordenar el mismo arreglo sin alteraciones.
Dado el conteo, parece ser que el insertionSort es el más eficiente de los dos.

/* Este programa implementara ambos algoritmos de ordenamiento estudiados hasta ahora
bubbleSort e insertionSort se pondra un contador adentro de cada iteración del algoritmo y devolvera
el número de veces que se hace una iteración.
El algoritmo ordenara los elementos del arreglo en orden ascendente.*/
#include <stdio.h>
#include <math.h>

int itBubble = 0, itInsertion = 0;

void printArray(int arr[], int n)
{
	int i;
	printf("\n");
	for (i = 0; i < n; i++)
	{
		printf("[%d]", arr[i]);
		if(i != 0 && i % 10 == 0)
			printf("\n");
	}
	printf("\n\n");
}

//InsertionSort
void insertionSort(int arr[], int n)
{
	int i, j, currentVal;
	for (i = 0; i < n; i++)
	{
		currentVal = arr[i];
		j = i-1;
		while (j >= 0 && arr[j] > currentVal) 
	   	{ 
			arr[j+1] = arr[j]; 
	        j = j-1;
	        itInsertion++; //Aumenta la iteración del insertionSort. 
	    } 
	    arr[j+1] = currentVal;
	    itInsertion++;  //Aumenta la iteración del insertionSort. 
	}
}

//BubbleSort
void swapPos(int *n1, int *n2)
{
	int temp = *n1;
	*n1 = *n2;
	*n2 = temp;
}

void bubbleSort(int arr[], int n)
{
	int i, j;
	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n-i-1; j++)
		{
			if(arr[j] > arr[j+1])
				swapPos(&arr[j], &arr[j+1]);
			itBubble++; //Aumenta la iteración del bubbleSort. 
		}
	}
}

int main(int argc, char const *argv[])
{
	int arr1[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,
		-6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887,
		5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984,
		4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076,
		4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032,
		6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794,
		-5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791,
		-4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
		-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
		-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891,
		-2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954,
		-362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
		-5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681,
		-9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23,
		8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
		4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
		6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
		-1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
		7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
		6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
		-9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236,
		3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137,
		200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741,
		-6953, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574,
		-7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
		7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674,
		4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234,
		-1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261,
		8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073,
		-239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595, 9995};

	int arr2[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,
		-6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887,
		5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984,
		4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076,
		4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032,
		6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794,
		-5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791,
		-4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
		-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
		-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891,
		-2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954,
		-362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
		-5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681,
		-9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23,
		8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
		4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
		6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
		-1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
		7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
		6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
		-9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236,
		3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137,
		200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741,
		-6953, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574,
		-7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
		7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674,
		4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234,
		-1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261,
		8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073,
		-239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595, 9995};

	int n1 = sizeof(arr1)/sizeof(arr1[0]);
	int n2 = sizeof(arr2)/sizeof(arr2[0]);

	printf("Ordenar un arreglo usando los algoritmos de bubbleSort e insertionSort en orden acendente.\n\n");
	printf("Numero de elementos: %d.\n\n", n1);

	printf("Arreglo original: ");
	printArray(arr1, n1);

	printf("Arreglo ordenado con bubbleSort: ");
	bubbleSort(arr1, n1);
	printArray(arr1, n1);

	printf("Arreglo ordenado con insertionSort: ");
	insertionSort(arr2, n2);
	printArray(arr2, n2);

	printf("Cantidad de iteraciones bubbleSort: %d.\n", itBubble);
	printf("Cantidad de iteraciones insertionSort: %d.\n", itInsertion);

	return 0;
}

Reto cumplido con el uso de C++;

#include <iostream>

using namespace std;
void insertionSort(int arr[], int n)
{
    int i, currenVal, j;
    for (i =1; i <n; i++)
    {
        currenVal = arr[i];
        j = i-1;
        while(j>= 0 && arr[j]< currenVal)
        {
            arr[j+1] = arr[j];
            j = j-1;
        }
        arr[j+1]=currenVal;
    }
}
void ChangePosition(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}
void bubblesort(int arr[],int n)
{
    int i,j;
    for(i=0; i<n-1; i++)
    {
        for(j=0; j<n-i; j++)
        {
            if(arr[j]<arr[j+1])
            {
                ChangePosition(&arr[j],&arr[j+1]);
            }
        }
    }
}

void printArray(int arr[], int n)
{
    int i;
    for(i=0; i<n; i++)
    {
        cout<<"|"<< arr[i];
    }
    cout <<""<< endl;
    cout<<"fin del ordenamiento"<<endl;
}

int main()
{
    string t = " ";
    bool q = true;
    int arr[]={-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,
		-6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887,
		5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984,
		4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076,
		4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032,
		6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794,
		-5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791,
		-4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222,
		-1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685,
		-4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891,
		-2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954,
		-362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
		-5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681,
		-9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23,
		8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
		4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
		6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
		-1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
		7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
		6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
		-9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236,
		3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137,
		200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741,
		-6953, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574,
		-7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
		7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674,
		4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234,
		-1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261,
		8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073,
		-239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595, 9995};
		 int n = sizeof(arr)/sizeof(arr[0]);

    cout << "ingrese a si quiere ordenar con insertion o s para ordenar con bubble" <<endl;

    while(q == true)
    {
        cin >> t;
        if(t == "a")
        {
            insertionSort(arr,n);
            printArray(arr,n);


        }else if(t == "s")
        {
            bubblesort(arr,n);
            printArray(arr,n);

        }else
        {
             q = false;

        }

    }

    return 0;
}```
# Crear una memoria de numeros.
numbers = []

# Abrir el archivo con los numeros.
file = open("numbers.txt")

# Por cada linea agregar a la coleccion su resultado en entero.
for line in file.readlines():
    numbers.append(int(line))

# Organizacion de tipo burbuja.
def bubbleSort(array: list):
    # Reconocer la longitud del arreglo.
    array_length = len(array)
    # Reciclar la longitud.
    for _ in range(array_length - 1):
        for i in range(array_length - 1):
            temp = array[i]
            if (array[i] > array[i + 1]):
                array[i] = array[i + 1]
                array[i + 1] = temp
    return array

bubbleSort(numbers)

# Imprimir la lista
print(*numbers, sep='\n')```

Puse el archivo de los números en un texto, y luego lo parsee a una lista de enteros.
#include <stdio.h>


/*Metodo de ordenamiento*/
void insertionSort(int *array, int n)
{
	int i, currentVal, j; 
	for (i = 1; i < n; i++) 
	{ 
		currentVal= array[i];
		j = i - 1;
		while (j >= 0 && array[j] > currentVal) 
		{ 
			array[j + 1] = array[j]; 
			j = j - 1; 
		} 
		array[j + 1] = currentVal; 
	} 
	
}

/*Imprimiendo matriz*/
void printArray(int *array, int n)
{
	for (int i = 0; i < n; i++)
	{
		if (i == (n - 1))
			printf("%d\n", array[i]);
		else
			printf("%d ,",array[i]);
	}
	printf("Fin del ordenamiento\n");
}

/*Metodo main*/
int main(int argc, char const *argv[])
{
	int array[] = {-796,3229,-5164 ,-362 ,4408 ,8965 ,-6068 ,9329 ,-3034 ,-443 ,-6693 ,9497 ,2615 ,-5966 ,-9065 ,-1160 ,6148 ,5517 ,1123 ,-8887 ,5649 ,3302 ,-1176 ,-8542 ,-9166 ,8 ,-2906 ,8987 ,-2414 ,-7984 ,4410 ,8872 ,5241 ,-4556 ,59 ,-5562 ,-3877 ,7452 ,-4467 ,2076 ,4076 ,4297 ,-3847 ,-2055 ,4483 ,-1484 ,-2371 ,6199 ,-7261 ,-7032 ,6010 ,2325 ,-6625 ,-2601 ,3870 ,1822 ,-5665 ,9622 ,9883 ,-5794 ,-5218 ,2926 ,8599 ,-3099 ,6399 ,-2570 ,3943 ,-2409 ,5114 ,9791 ,-4420 ,1065 ,3077 ,-1062 ,-8004 ,4397 ,1635 ,8578 ,-9226 ,9222 ,-1793 ,-2691 ,-5060 ,-4727 ,-4098 ,946 ,-6558 ,-4111 ,4575 ,-2685 ,-4729 ,-5277 ,1936 ,5106 ,-2089 ,824 ,9421 ,-1683 ,-2083 ,7891 ,-2099 ,1305 ,-9076 ,-3535 ,2565 ,-2871 ,9448 ,7177 ,-8614 ,-9954 ,-362 ,1455 ,-8834 ,-9846 ,-8412 ,1175 ,-1981 ,-5991 ,7201 ,-1997 ,-5156 ,-1634 ,-9803 ,1032 ,9551 ,-6153 ,8502 ,3536 ,-2980 ,8681 ,-9210 ,4408 ,8780 ,-916 ,-369 ,-8651 ,1246 ,-702 ,-5555 ,23 ,8208 ,2037 ,6941 ,9545 ,-5147 ,5063 ,-8358 ,2772 ,8553 ,9885 ,4624 ,-3576 ,9131 ,1229 ,-429 ,-479 ,-673 ,-7060 ,-4031 ,5650 ,6679 ,6796 ,5622 ,-6256 ,-238 ,-6096 ,3096 ,-1610 ,-2948 ,6291 ,-1666 ,5219 ,5850 ,7387 ,-3260 ,3672 ,-1766 ,-9941 ,8252 ,2649 ,7079 ,-8026 ,6356 ,676 ,-5065 ,-6338 ,3287 ,680 ,-3269 ,2770 ,6637 ,-8744 ,9162 ,-2204 ,-3066 ,-7228 ,8762 ,1505 ,4957 ,766 ,-9136 ,4632 ,-5022 ,-9999 ,5361 ,2732 ,7831 ,-501 ,-4650 ,7236 ,3682 ,-2438 ,5574 ,-8230 ,-9669 ,-7442 ,7966 ,-2905 ,7629 ,7137 ,200 ,-8670 ,-749 ,2228 ,458 ,7889 ,-3668 ,-5350 ,-3261 ,6741 ,-6953 ,4800 ,3372 ,6662 ,-1018 ,8523 ,3164 ,3577 ,9720 ,-6826 ,-1574 ,-7875 ,-2796 ,-1078 ,-4755 ,4926 ,3368 ,4302 ,9254 ,6410 ,-4689 ,7878 ,2461 ,8233 ,-6688 ,5904 ,4735 ,-2940 ,8830 ,9976 ,-3674 ,4222 ,-1446 ,6187 ,-3181 ,-8882 ,5487 ,-6939 ,-7885 ,3786 ,-6234 ,-1062 ,-4553 ,-5709 ,8459 ,5008 ,3352 ,6586 ,537 ,-7610 ,3261 ,8246 ,-2105 ,5107 ,7957 ,-7886 ,-2925 ,-2541 ,-7449-796,3229,-5164,-362 ,4408 ,8965 ,-6068 ,9329 ,-3034 ,-443 ,-6693 ,9497 ,2615 ,-5966 ,-9065 ,-1160 ,6148 ,5517 ,1123 ,-8887 ,5649 ,3302 ,-1176 ,-8542 ,-9166 ,8 ,-2906 ,8987 ,-2414 ,-7984 ,4410 ,8872 ,5241 ,-4556 ,59 ,-5562 ,-3877 ,7452 ,-4467 ,2076 ,4076 ,4297 ,-3847 ,-2055 ,4483 ,-1484 ,-2371 ,6199 ,-7261 ,-7032 ,6010 ,2325 ,-6625 ,-2601 ,3870 ,1822 ,-5665 ,9622 ,9883 ,-5794 ,-5218 ,2926 ,8599 ,-3099 ,6399 ,-2570 ,3943 ,-2409 ,5114 ,9791 ,-4420 ,1065 ,3077 ,-1062 ,-8004 ,4397 ,1635 ,8578 ,-9226 ,9222 ,-1793 ,-2691 ,-5060 ,-4727 ,-4098 ,946 ,-6558 ,-4111 ,4575 ,-2685 ,-4729 ,-5277 ,1936 ,5106 ,-2089 ,824 ,9421 ,-1683 ,-2083 ,7891 ,-2099 ,1305 ,-9076 ,-3535 ,2565 ,-2871 ,9448 ,7177 ,-8614 ,-9954 ,-362 ,1455 ,-8834 ,-9846 ,-8412 ,1175 ,-1981 ,-5991 ,7201 ,-1997 ,-5156 ,-1634 ,-9803 ,1032 ,9551 ,-6153 ,8502 ,3536 ,-2980 ,8681 ,-9210 ,4408 ,8780 ,-916 ,-369 ,-8651 ,1246 ,-702 ,-5555 ,23 ,8208 ,2037 ,6941 ,9545 ,-5147 ,5063 ,-8358 ,2772 ,8553 ,9885 ,4624 ,-3576 ,9131 ,1229 ,-429 ,-479 ,-673 ,-7060 ,-4031 ,5650 ,6679 ,6796 ,5622 ,-6256 ,-238 ,-6096 ,3096 ,-1610 ,-2948 ,6291 ,-1666 ,5219 ,5850 ,7387 ,-3260 ,3672 ,-1766 ,-9941 ,8252 ,2649 ,7079 ,-8026 ,6356 ,676 ,-5065 ,-6338 ,3287 ,680 ,-3269 ,2770 ,6637 ,-8744 ,9162 ,-2204 ,-3066 ,-7228 ,8762 ,1505 ,4957 ,766 ,-9136 ,4632 ,-5022 ,-9999 ,5361 ,2732 ,7831 ,-501 ,-4650 ,7236 ,3682 ,-2438 ,5574 ,-8230 ,-9669 ,-7442 ,7966 ,-2905 ,7629 ,7137 ,200 ,-8670 ,-749 ,2228 ,458 ,7889 ,-3668 ,-5350 ,-3261 ,6741 ,-6953 ,4800 ,3372 ,6662 ,-1018 ,8523 ,3164 ,3577 ,9720 ,-6826 ,-1574 ,-7875 ,-2796 ,-1078 ,-4755 ,4926 ,3368 ,4302 ,9254 ,6410 ,-4689 ,7878 ,2461 ,8233 ,-6688 ,5904 ,4735 ,-2940 ,8830 ,9976 ,-3674 ,4222 ,-1446 ,6187 ,-3181 ,-8882 ,5487 ,-6939 ,-7885 ,3786 ,-6234 ,-1062 ,-4553 ,-5709 ,8459 ,5008 ,3352 ,6586 ,537 ,-7610 ,3261 ,8246 ,-2105 ,5107 ,7957 ,-7886 ,-2925 ,-2541 ,-7449 ,9521 ,5073 ,-239 ,-8054 ,-4379 ,-8323 ,-6485 ,-4828 ,-5294 ,-2720 ,595};
	int n = sizeof(array) / sizeof(array[0]);

	insertionSort(array, n);
	printArray(array, n);
	return (0);
}

Aquí mi solución. Implementé Insertion-Sort en C, gracias al Curso de Introducción a C

![](

![](

Pueden bajar el código de aquí: https://github.com/jcalvarezj/practice/blob/master/C/insertionData.c

Para este desafío use dos métodos distintos y en dos lenguajes diferentes C y JS:

En C

#include "stdio.h"

void organizar(int Array[], int Length)
{
    int j, a, temp;
    for (j = 0; j < Length; j++)
    {
        for(a=j+1; a < Length; a++)
        {
            if (Array[j] < Array[a])
            {
                temp = Array[j];
                Array[j]=Array[a];
                Array[a]=temp;
            }
        }
    }
}

void imprimir(int Array[], int Length)
{
    int i;
    for (i = 0; i < Length-1; i++)
    {
        printf("%d, ",Array[i]);
    }
    printf("%d.",Array[Length-1]);
    
}

int main(int argc, char const *argv[])
{
    int Array[]={-796,	3229,	-5164,	-362,	4408,	8965,	-6068,	9329,	-3034,	-443,	-6693,	9497,	2615,	-5966,	-9065,	-1160,	6148,	5517,	1123,	-8887,	5649,	3302,	-1176,	-8542,	-9166,	8,	-2906,	8987,	-2414,	-7984,	4410,	8872,	5241,	-4556,	59,	-5562,	-3877,	7452,	-4467,	2076,	4076,	4297,	-3847,	-2055,	4483,	-1484,	-2371,	6199,	-7261,	-7032,	6010,	2325,	-6625,	-2601,	3870,	1822,	-5665,	9622,	9883,	-5794,	-5218,	2926,	8599,	-3099,	6399,	-2570,	3943,	-2409,	5114,	9791,	-4420,	1065,	3077,	-1062,	-8004,	4397,	1635,	8578,	-9226,	9222,	-1793,	-2691,	-5060,	-4727,	-4098,	946,	-6558,	-4111,	4575,	-2685,	-4729,	-5277,	1936,	5106,	-2089,	824,	9421,	-1683,	-2083,	7891,	-2099,	1305,	-9076,	-3535,	2565,	-2871,	9448,	7177,	-8614,	-9954,	-362,	1455,	-8834,	-9846,	-8412,	1175,	-1981,	-5991,	7201,	-1997,	-5156,	-1634,	-9803,	1032,	9551,	-6153,	8502,	3536,	-2980,	8681,	-9210,	4408,	8780,	-916,	-369,	-8651,	1246,	-702,	-5555,	23,	8208,	2037,	6941,	9545,	-5147,	5063,	-8358,	2772,	8553,	9885,	4624,	-3576,	9131,	1229,	-429,	-479,	-673,	-7060,	-4031,	5650,	6679,	6796,	5622,	-6256,	-238,	-6096,	3096,	-1610,	-2948,	6291,	-1666,	5219,	5850,	7387,	-3260,	3672,	-1766,	-9941,	8252,	2649,	7079,	-8026,	6356,	676,	-5065,	-6338,	3287,	680,	-3269,	2770,	6637,	-8744,	9162,	-2204,	-3066,	-7228,	8762,	1505,	4957,	766,	-9136,	4632,	-5022,	-9999,	5361,	2732,	7831,	-501,	-4650,	7236,	3682,	-2438,	5574,	-8230,	-9669,	-7442,	7966,	-2905,	7629,	7137,	200,	-8670,	-749,	2228,	458,	7889,	-3668,	-5350,	-3261,	6741,	-6953,	4800,	3372,	6662,	-1018,	8523,	3164,	3577,	9720,	-6826,	-1574,	-7875,	-2796,	-1078,	-4755,	4926,	3368,	4302,	9254,	6410,	-4689,	7878,	2461,	8233,	-6688,	5904,	4735,	-2940,	8830,	9976,	-3674,	4222,	-1446,	6187,	-3181,	-8882,	5487,	-6939,	-7885,	3786,	-6234,	-1062,	-4553,	-5709,	8459,	5008,	3352,	6586,	537,	-7610,	3261,	8246,	-2105,	5107,	7957,	-7886,	-2925,	-2541,	-7449,	9521,	5073,	-239,	-8054,	-4379,	-8323,	-6485,	-4828,	-5294,	-2720,	595};
    int Length = sizeof(Array)/sizeof(Array[0]);

    organizar(Array, Length);
    imprimir(Array, Length);

    return 0;
}

Y en JS:

var Numeros=[-796,	3229,	-5164,	-362,	4408,	8965,	-6068,	9329,	-3034,	-443,	-6693,	9497,	2615,	-5966,	-9065,	-1160,	6148,	5517,	1123,	-8887,	5649,	3302,	-1176,	-8542,	-9166,	8,	-2906,	8987,	-2414,	-7984,	4410,	8872,	5241,	-4556,	59,	-5562,	-3877,	7452,	-4467,	2076,	4076,	4297,	-3847,	-2055,	4483,	-1484,	-2371,	6199,	-7261,	-7032,	6010,	2325,	-6625,	-2601,	3870,	1822,	-5665,	9622,	9883,	-5794,	-5218,	2926,	8599,	-3099,	6399,	-2570,	3943,	-2409,	5114,	9791,	-4420,	1065,	3077,	-1062,	-8004,	4397,	1635,	8578,	-9226,	9222,	-1793,	-2691,	-5060,	-4727,	-4098,	946,	-6558,	-4111,	4575,	-2685,	-4729,	-5277,	1936,	5106,	-2089,	824,	9421,	-1683,	-2083,	7891,	-2099,	1305,	-9076,	-3535,	2565,	-2871,	9448,	7177,	-8614,	-9954,	-362,	1455,	-8834,	-9846,	-8412,	1175,	-1981,	-5991,	7201,	-1997,	-5156,	-1634,	-9803,	1032,	9551,	-6153,	8502,	3536,	-2980,	8681,	-9210,	4408,	8780,	-916,	-369,	-8651,	1246,	-702,	-5555,	23,	8208,	2037,	6941,	9545,	-5147,	5063,	-8358,	2772,	8553,	9885,	4624,	-3576,	9131,	1229,	-429,	-479,	-673,	-7060,	-4031,	5650,	6679,	6796,	5622,	-6256,	-238,	-6096,	3096,	-1610,	-2948,	6291,	-1666,	5219,	5850,	7387,	-3260,	3672,	-1766,	-9941,	8252,	2649,	7079,	-8026,	6356,	676,	-5065,	-6338,	3287,	680,	-3269,	2770,	6637,	-8744,	9162,	-2204,	-3066,	-7228,	8762,	1505,	4957,	766,	-9136,	4632,	-5022,	-9999,	5361,	2732,	7831,	-501,	-4650,	7236,	3682,	-2438,	5574,	-8230,	-9669,	-7442,	7966,	-2905,	7629,	7137,	200,	-8670,	-749,	2228,	458,	7889,	-3668,	-5350,	-3261,	6741,	-6953,	4800,	3372,	6662,	-1018,	8523,	3164,	3577,	9720,	-6826,	-1574,	-7875,	-2796,	-1078,	-4755,	4926,	3368,	4302,	9254,	6410,	-4689,	7878,	2461,	8233,	-6688,	5904,	4735,	-2940,	8830,	9976,	-3674,	4222,	-1446,	6187,	-3181,	-8882,	5487,	-6939,	-7885,	3786,	-6234,	-1062,	-4553,	-5709,	8459,	5008,	3352,	6586,	537,	-7610,	3261,	8246,	-2105,	5107,	7957,	-7886,	-2925,	-2541,	-7449,	9521,	5073,	-239,	-8054,	-4379,	-8323,	-6485,	-4828,	-5294,	-2720,	595];

var largo = Numeros.length;
var temp, cont;
var conf = true;

BubbleSort();
imprimir();

function BubbleSort()
{
    while(conf)
    {
        cont = 0;
        for (var i = 0; i < largo-1; i++)  
        {
            if (Numeros[i]<Numeros[i+1])
            {
                temp = Numeros[i];
                Numeros[i] = Numeros[i+1];
                Numeros[i+1] = temp;
                cont ++;
            }
            console.log(cont+" "+conf)
        }
        if (cont == 0)
        {
            console.log(cont+" Entro al if")
            conf = false;
        }
    }
}

function imprimir()
{
    var escribir = document.getElementById('orden');
    escribir.innerHTML = Numeros;
}

He realizado el ejercicio utilizando el algoritmo de insertion sort obteniendo el listado de números a partir de un archivo de texto
Aquí el código:

/*
 * Implement sorting algorithm with a list of numbers defined in numbers.txt file
 * File content:
 * -796
3229
-5164
-362
4408
8965
-6068
9329
-3034
-443
-6693
9497
2615
-5966
-9065
-1160
6148
5517
1123
-8887
5649
3302
-1176
-8542
-9166
8
-2906
8987
-2414
-7984
4410
8872
5241
-4556
59
-5562
-3877
7452
-4467
2076
4076
4297
-3847
-2055
4483
-1484
-2371
6199
-7261
-7032
6010
2325
-6625
-2601
3870
1822
-5665
9622
9883
-5794
-5218
2926
8599
-3099
6399
-2570
3943
-2409
5114
9791
-4420
1065
3077
-1062
-8004
4397
1635
8578
-9226
9222
-1793
-2691
-5060
-4727
-4098
946
-6558
-4111
4575
-2685
-4729
-5277
1936
5106
-2089
824
9421
-1683
-2083
7891
-2099
1305
-9076
-3535
2565
-2871
9448
7177
-8614
-9954
-362
1455
-8834
-9846
-8412
1175
-1981
-5991
7201
-1997
-5156
-1634
-9803
1032
9551
-6153
8502
3536
-2980
8681
-9210
4408
8780
-916
-369
-8651
1246
-702
-5555
23
8208
2037
6941
9545
-5147
5063
-8358
2772
8553
9885
4624
-3576
9131
1229
-429
-479
-673
-7060
-4031
5650
6679
6796
5622
-6256
-238
-6096
3096
-1610
-2948
6291
-1666
5219
5850
7387
-3260
3672
-1766
-9941
8252
2649
7079
-8026
6356
676
-5065
-6338
3287
680
-3269
2770
6637
-8744
9162
-2204
-3066
-7228
8762
1505
4957
766
-9136
4632
-5022
-9999
5361
2732
7831
-501
-4650
7236
3682
-2438
5574
-8230
-9669
-7442
7966
-2905
7629
7137
200
-8670
-749
2228
458
7889
-3668
-5350
-3261
6741
-6953
4800
3372
6662
-1018
8523
3164
3577
9720
-6826
-1574
-7875
-2796
-1078
-4755
4926
3368
4302
9254
6410
-4689
7878
2461
8233
-6688
5904
4735
-2940
8830
9976
-3674
4222
-1446
6187
-3181
-8882
5487
-6939
-7885
3786
-6234
-1062
-4553
-5709
8459
5008
3352
6586
537
-7610
3261
8246
-2105
5107
7957
-7886
-2925
-2541
-7449
9521
5073
-239
-8054
-4379
-8323
-6485
-4828
-5294
-2720
595
 */

#include <stdio.h>
#include <stdlib.h>

void fill_vector_data(int vector[], int count) {
    FILE* fp = fopen("numbers.txt", "r");
    int aux;
    for (int i = 0; i < count; i++) {
        fscanf(fp, "%d", &vector[i]);
    }
    fclose(fp);
}

void insertion_sort(int vector[], int n) {
    int i, j, current;
    for (i = 0; i < n; i++) {
        current = vector[i];
        j = i-1;
        while (j >= 0 && vector[j] < current) {
            vector[j+1] = vector[j];
            j -= 1;
        }
        vector[j+1] = current;
    }
}

void print_vector(int vector[], int n) {
    printf("Vector = ");
    printf("{ ");
    for (int i = 0; i < n; i++) {
        if (i == n-1) {
            printf("%d", vector[i]);
        } else {
            printf("%d, ", vector[i]);
        }
    }
    printf(" }\n");
}

int main() {
    int n = 300;
    int vector[n]; 
    fill_vector_data(vector, n);

    printf("Start\n");
    print_vector(vector, n);

    insertion_sort(vector, n);
    
    printf("\nFinished\n");
    print_vector(vector, n);
    return 0;
}```

AQUI LES DEJO MI CODIGO CON JS.

function quickSort(arr){
    if(arr.length < 1){
        return [];
    }
    var left = [];
    var right = [];
    var pivot = arr[0];

    for (var i=1;i < arr.length;i++){
        if(arr[i]<pivot){
            left.push(arr[i]);
        }
        else {
            right.push(arr[i]);
        }
    }
    return[].concat(quickSort(left),pivot,quickSort(right));

}
console.log(quickSort([-796,
    3229,
    -5164,
    -362,
    4408,
    8965,
    -6068,
    9329,
    -3034,
    -443,
    -6693,
    9497,
    2615,
    -5966,
    -9065,
    -1160,
    6148,
    5517,
    1123,
    -8887,
    5649,
    3302,
    -1176,
    -8542,
    -9166,
    8,
    -2906,
    8987,
    -2414,
    -7984,
    4410,
    8872,
    5241,
    -4556,
    59,
    -5562,
    -3877,
    7452,
    -4467,
    2076,
    4076,
    4297,
    -3847,
    -2055,
    4483,
    -1484,
    -2371,
    6199,
    -7261,
    -7032,
    6010,
    2325,
    -6625,
    -2601,
    3870,
    1822,
    -5665,
    9622,
    9883,
    -5794,
    -5218,
    2926,
    8599,
    -3099,
    6399,
    -2570,
    3943,
    -2409,
    5114,
    9791,
    -4420,
    1065,
    3077,
    -1062,
    -8004,
    4397,
    1635,
    8578,
    -9226,
    9222,
    -1793,
    -2691,
    -5060,
    -4727,
    -4098,
    946,
    -6558,
    -4111,
    4575,
    -2685,
    -4729,
    -5277,
    1936,
    5106,
    -2089,
    824,
    9421,
    -1683,
    -2083,
    7891,
    -2099,
    1305,
    -9076,
    -3535,
    2565,
    -2871,
    9448,
    7177,
    -8614,
    -9954,
    -362,
    1455,
    -8834,
    -9846,
    -8412,
    1175,
    -1981,
    -5991,
    7201,
    -1997,
    -5156,
    -1634,
    -9803,
    1032,
    9551,
    -6153,
    8502,
    3536,
    -2980,
    8681,
    -9210,
    4408,
    8780,
    -916,
    -369,
    -8651,
    1246,
    -702,
    -5555,
    23,
    8208,
    2037,
    6941,
    9545,
    -5147,
    5063,
    -8358,
    2772,
    8553,
    9885,
    4624,
    -3576,
    9131,
    1229,
    -429,
    -479,
    -673,
    -7060,
    -4031,
    5650,
    6679,
    6796,
    5622,
    -6256,
    -238,
    -6096,
    3096,
    -1610,
    -2948,
    6291,
    -1666,
    5219,
    5850,
    7387,
    -3260,
    3672,
    -1766,
    -9941,
    8252,
    2649,
    7079,
    -8026,
    6356,
    676,
    -5065,
    -6338,
    3287,
    680,
    -3269,
    2770,
    6637,
    -8744,
    9162,
    -2204,
    -3066,
    -7228,
    8762,
    1505,
    4957,
    766,
    -9136,
    4632,
    -5022,
    -9999,
    5361,
    2732,
    7831,
    -501,
    -4650,
    7236,
    3682,
    -2438,
    5574,
    -8230,
    -9669,
    -7442,
    7966,
    -2905,
    7629,
    7137,
    200,
    -8670,
    -749,
    2228,
    458,
    7889,
    -3668,
    -5350,
    -3261,
    6741,
    -6953,
    4800,
    3372,
    6662,
    -1018,
    8523,
    3164,
    3577,
    9720,
    -6826,
    -1574,
    -7875,
    -2796,
    -1078,
    -4755,
    4926,
    3368,
    4302,
    9254,
    6410,
    -4689,
    7878,
    2461,
    8233,
    -6688,
    5904,
    4735,
    -2940,
    8830,
    9976,
    -3674,
    4222,
    -1446,
    6187,
    -3181,
    -8882,
    5487,
    -6939,
    -7885,
    3786,
    -6234,
    -1062,
    -4553,
    -5709,
    8459,
    5008,
    3352,
    6586,
    537,
    -7610,
    3261,
    8246,
    -2105,
    5107,
    7957,
    -7886,
    -2925,
    -2541,
    -7449,
    9521,
    5073,
    -239,
    -8054,
    -4379,
    -8323,
    -6485,
    -4828,
    -5294,
    -2720,
    595]))```

Cocktail Sort o Ordenamiento de Burbuja Bidireccional es una versión mejorada del ordenamiento de burbuja que hace dos pasadas una de izquierda a derecha y otra de derecha a izquierda. Aquí la cantidad de números que se evalúan en comparación con el bubble sort es menor

Aquí el código muy parecido al Bubble sort:

#include<stdio.h>

void change_pos(int *n1, int *n2)
{
  int temp = *n1;
  *n1 = *n2;
  *n2 = temp;
}

void cocktailSort(int arr[], int n)
{
  int swapped = 1;
  int start = 0;
  int end = n;

  while(swapped = 1){
    swapped = 0;

    for(int i = start; i < end - 1; i++)
    {
      //[10, 5, 3, 3333]
      if(arr[i] > arr[i+1])
        change_pos(&arr[i], &arr[i+1]);
        swapped = 1;
    }

    if (swapped == 0)
      break;

    swapped = 0;

    end = end - 1;
    
    for(int i = end - 1; i >= start; i--)
    {
      //[10, 5, 3, 3333]
      if(arr[i] > arr[i+1]) {
        change_pos(&arr[i], &arr[i+1]);
        swapped = 1;
      }
    }
    start = start + 1;
  };
  

}


int printArray(int input_array[], int n) 
{
  int i; 
  for(i = 0; i < n; i++)
    printf("%d,  ", input_array[i]);
  printf("\n fin del ordenamiento");
}

int main(int argc, char const *argv[])
{
  int input_vector[]={-796, 3229, -5164, 
  -362, 4408, 8965, -6068, 9329, -3034, -443, 
  -6693, 9497, 2615, -5966, -9065, -1160, 6148, 
  5517, 1123, -8887, 5649, 3302, -1176, -8542, 
  -9166, 8, -2906, 8987, -2414, -7984, 4410, 
  8872, 5241, -4556, 59, -5562, -3877, 7452, 
  -4467, 2076, 4076, 4297, -3847, -2055, 4483,
  -1484, -2371, 6199, -7261, -7032, 6010, 2325, 
  -6625, -2601, 3870, 1822, -5665, 9622, 9883, 
  -5794, -5218, 2926, 8599, -3099, 6399, -2570, 
  3943, -2409, 5114, 9791, -4420, 1065, 3077, 
  -1062, -8004, 4397, 1635, 8578, -9226, 9222, 
  -1793, -2691, -5060, -4727, -4098, 946, -6558, 
  -4111, 4575, -2685, -4729, -5277, 1936, 5106, 
  -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305,
  -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954, 
  -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 
  7201, -1997, -5156, -1634, -9803, 1032, 9551, -6153, 
  8502, 3536, -2980, 8681, -9210, 4408, 8780, -916, -369,
  -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, 
  -5147, 5063, -8358, 2772, 8553, 9885, 4624, -3576, 9131, 
  1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796,
  5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 
  5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649, 
  7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 
  2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505,
  4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, 
  -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, 
  -2905, 7629, 7137, 200, -8670, -749, 2228, 458, 7889, -3668, 
  -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 
  3164, 3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 
  4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 
  5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, 
  -8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 
  8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957,
  -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323,
  -6485, -4828, -5294, -2720, 595};
  int n = sizeof(input_vector)/sizeof(input_vector[0]);
  cocktailSort(input_vector, n);
  printArray(input_vector, n);
  printf("\n");
  return 0;
}
Array de 300 elementos ordenado

 -9999, -9954, -9941, -9846, -9803, -9669, -9226, -9210, -9166, -9136, -9076, -9065, -8887, -8882, -8834, -8744, -8670, -8651, -8614, -8542, -8412, -8358, -8323, -8230, -8054, -8026, -8004, -7984, -7886, -7885, -7875, -7610, -7449, -7442, -7261, -7228, -7060, -7032, -6953, -6939, -6826, -6693, -6688, -6625, -6558, -6485, -6338, -6256, -6234, -6153, -6096, -6068, -5991, -5966, -5794, -5709, -5665, -5562, -5555, -5350, -5294, -5277, -5218, -5164, -5156, -5147, -5065, -5060, -5022, -4828, -4755, -4729, -4727, -4689, -4650, -4556, -4553, -4467, -4420, -4379, -4111, -4098, -4031, -3877, -3847, -3674, -3668, -3576, -3535, -3269, -3261, -3260, -3181, -3099, -3066, -3034, -2980, -2948, -2940, -2925, -2906, -2905, -2871, -2796, -2720, -2691, -2685, -2601, -2570, -2541, -2438, -2414, -2409, -2371, -2204, -2105, -2099, -2089, -2083, -2055, -1997, -1981, -1793, -1766, -1683, -1666, -1634, -1610, -1574, -1484, -1446, -1176, -1160, -1078, -1062, -1062, -1018, -916, -749, -702, -673, -501, -479, -443, -429, -369, -362, -362, -239, -238, 8, 23, 59, 200, 458, 537, 595, 676, 680, 766, 796, 824, 946, 1032, 1065, 1123, 1175, 1229, 1246, 1305, 1455, 1505, 1635, 1822, 1936, 2037, 2076, 2228, 2325, 2461, 2565, 2615, 2649, 2732, 2770, 2772, 2926, 3077, 3096, 3164, 3229, 3261, 3287, 3302, 3352, 3368, 3372, 3536, 3577, 3672, 3682, 3786, 3870, 3943, 4076, 4222, 4297, 4302, 4397, 4408, 4408, 4410, 4483, 4575, 4624, 4632, 4735, 4800, 4926, 4957, 5008, 5063, 5073, 5106, 5107, 5114, 5219, 5241, 5361, 5487, 5517, 5574, 5622, 5649, 5650, 5850, 5904, 6010, 6148, 6187, 6199, 6291, 6356, 6399, 6410, 6586, 6637, 6662, 6679, 6741, 6796, 6941, 7079, 7137, 7177, 7201, 7236, 7387, 7452, 7629, 7831, 7878, 7889, 7891, 7957, 7966, 8208, 8233, 8246, 8252, 8459, 8502, 8523, 8553, 8578, 8599, 8681, 8762, 8780, 8830, 8872, 8965, 8987, 9131, 9162, 9222, 9254, 9329, 9421, 9448, 9497, 9521, 9545, 9551, 9622, 9720, 9791, 9883, 9885, 9976,
 Fin del ordenamiento
Llenando el Array...
Llenado terminado ...
What kind of sort do u want? : a) Increasing   b) Decreasing
b
The ordered numbers are: [9976, 9885, 9883, 9791, 9720, 9622, 9551, 9545, 9521, 9497, 9448, 9421, 9329, 9254, 9222, 9162, 9131, 8987, 8965, 8872, 8830, 8780, 8762, 8681, 8599, 8578, 8553, 8523, 8502, 8459, 8252, 8246, 8233, 8208, 7966, 7957, 7891, 7889, 7878, 7831, 7629, 7452, 7387, 7236, 7201, 7177, 7137, 7079, 6941, 6796, 6741, 6679, 6662, 6637, 6586, 6410, 6399, 6356, 6291, 6199, 6187, 6148, 6010, 5904, 5850, 5650, 5649, 5622, 5574, 5517, 5487, 5361, 5241, 5219, 5114, 5107, 5106, 5073, 5063, 5008, 4957, 4926, 4800, 4735, 4632, 4624, 4575, 4483, 4410, 4408, 4408, 4397, 4302, 4297, 4222, 4076, 3943, 3870, 3786, 3682, 3672, 3577, 3536, 3372, 3368, 3352, 3302, 3287, 3261, 3229, 3164, 3096, 3077, 2926, 2772, 2770, 2732, 2649, 2615, 2565, 2461, 2325, 2228, 2076, 2037, 1936, 1822, 1635, 1505, 1455, 1305, 1246, 1229, 1175, 1123, 1065, 1032, 946, 824, 766, 680, 676, 595, 537, 458, 200, 59, 23, 8, -238, -239, -362, -362, -369, -429, -443, -479, -501, -673, -702, -749, -796, -916, -1018, -1062, -1062, -1078, -1160, -1176, -1446, -1484, -1574, -1610, -1634, -1666, -1683, -1766, -1793, -1981, -1997, -2055, -2083, -2089, -2099, -2105, -2204, -2371, -2409, -2414, -2438, -2541, -2570, -2601, -2685, -2691, -2720, -2796, -2871, -2905, -2906, -2925, -2940, -2948, -2980, -3034, -3066, -3099, -3181, -3260, -3261, -3269, -3535, -3576, -3668, -3674, -3847, -3877, -4031, -4098, -4111, -4379, -4420, -4467, -4553, -4556, -4650, -4689, -4727, -4729, -4755, -4828, -5022, -5060, -5065, -5147, -5156, -5164, -5218, -5277, -5294, -5350, -5555, -5562, -5665, -5709, -5794, -5966, -5991, -6068, -6096, -6153, -6234, -6256, -6338, -6485, -6558, -6625, -6688, -6693, -6826, -6939, -6953, -7032, -7060, -7228, -7261, -7442, -7449, -7610, -7875, -7885, -7886, -7984, -8004, -8026, -8054, -8230, -8323, -8358, -8412, -8542, -8614, -8651, -8670, -8744, -8834, -8882, -8887, -9065, -9076, -9136, -9166, -9210, -9226, -9669, -9803, -9846, -9941, -9954, -9999]

Process finished with exit code 0

Aqui esta mi desafio, copie todos los numeros en un archivo y desde ahi el programa carga los numeros y los ordena por el metodo de insercion , los muestra en la consola y los guarda ya ordenados en un nuevo archivo de texto, aqui esta el codigo si alguien quiere checarlo
https://drive.google.com/open?id=1Mc4wrgnEoiGxzVPZa00V9cmx51HLEzRj
Este es mi codigo:

#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

//Variables globales
int lista = 0; // cantidad de elementos en la lista de Numeros
string numeros;
ifstream listaNumeros;
ofstream nuevaListaNumeros;
bool archivoOpen = true;
//Prototipos de Funciones
void verificarArchivo(bool &);
void contandoNumElementosArchivo();
void archivoAArray();
void ordenamientoInsercion(int *);
void mostrandoResultado(int *);

int main(){
  contandoNumElementosArchivo();
  archivoAArray();
  return 0;
}
//Esta funcion verificara si no hay error al intertar abrir o crear el archivo
void verificarArchivo(bool &archivoOpen){
  if(archivoOpen){ //esta condicional leera el archivo
    listaNumeros.open("ListadeNumeros.txt", ios::in);
    if(listaNumeros.fail()){
      cout<<"Hubo ur error al intentar abrir el archivo "<<endl;
      exit(1);
    }
  }
  else{ // creara y abrira el archivo para la salida de numeros ordenados
    nuevaListaNumeros.open("nuevaListaNumeros.txt", ios::out);
    if(nuevaListaNumeros.fail()){
      cout<<"Hubo ur error al crear el archivo "<<endl;
      exit(1);
    }
  }
}
//Esta funcion contara el numero de elementos que hay en la lista
void contandoNumElementosArchivo(){
  verificarArchivo(archivoOpen);
  //Cuenta la cantidad de numeros que hay en el archivo
  while (!listaNumeros.eof()) {
    getline(listaNumeros, numeros);
    if(numeros != ""){
      lista++;
    }
  }
  listaNumeros.close();
}
// esta funcion copiara todos los elementos en un vector
void archivoAArray(){
  int recorrido = 0;
  int num[lista]; // creacion estatica del vector
  verificarArchivo(archivoOpen);
//copiando lo que hay en la lista en el vector
  while (!listaNumeros.eof()) {
    getline(listaNumeros, numeros);
    if(numeros != ""){
      num[recorrido] = stoi(numeros); // convirtiendo el string en int hacia el vector
      recorrido++;
    }
  }
  listaNumeros.close();
  ordenamientoInsercion(num); // llamando la funcion para ordenar el vector
  mostrandoResultado(num);
}
//Esta funcion hace ordenamiento por el Metodo de insercion
void ordenamientoInsercion(int *num){
    int apunta, aux;
    cout<<"Tamanio de la lista: "<<lista<<endl;
    //Algoritmo metodo de insercion
    for(int i = 0; i < lista; i++){
      apunta = i;
      aux = num[i];
      while ( (apunta > 0) && (num[apunta - 1] > aux)) {
          num[apunta] = num[apunta - 1];
          apunta--;
      }
      num[apunta] = aux;
    }
}

void mostrandoResultado(int *num){
  //string ordenNumeros;
  archivoOpen = false;  //
  // mostrando el resultado en consola y pasandolo al archivo de texto
  cout<<"Orden Descendente"<<endl;
  verificarArchivo(archivoOpen);
  for(int i = lista - 1; i >= 0; i--){
    //ordenNumeros = to_string(num[i]); este codigo esta comentado ya que anteriormente convertia los numeros en string y los pasaba en el archivo
    nuevaListaNumeros<<num[i]<<endl;
    cout<<num[i]<<endl;
  }
  nuevaListaNumeros.close();
}

`<code>
/*
Implementación de Insertion Sort.
La lista de números se lee desde un archivo de texto.
*/
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 1000
int ptr_lista[MAX_SIZE];
int max_items;

void swap(int *n1, int *n2){
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void insertionSort(int ptr_lista[], int max_items){
    int i;
    int j;
    if(max_items == 1)
        printf("lista de numeros esta ordenado");
    else{
        for(i=0; i<max_items-1; i++){
            j=i+1;
            while(j>=1 && ptr_lista[j]>ptr_lista[j-1]){
                swap(&ptr_lista[j-1], &ptr_lista[j]);
                j--;
            }
        }
    }
}

void read_list(char filename[]){
    FILE* ptr_file;
    int i = 0;
    ptr_file = fopen(filename, "r");
    while ( i < MAX_SIZE && fscanf (ptr_file, "%d", &ptr_lista[i++]) != -1);
    max_items = i - 1;
    fclose(ptr_file);
}

void print_array(int array_in[], int n){
    int i;
    for(i=0;i < n; i++)
        printf("%d ,", array_in[i]);
    printf("\n");
}

int main(int argc, char const *argv[])
{
    char file_path[] = "lista_desordenada.txt";
    read_list(file_path);
    print_array(ptr_lista,max_items);
    insertionSort(ptr_lista,max_items);   
    print_array(ptr_lista,max_items);
    return 0;
}
    
Salida

9976 ,9885 ,9883 ,9791 ,9720 ,9622 ,9551 ,9545 ,9521 ,9497 ,9448 ,9421 ,9329 ,9254 ,9222 ,9162 ,9131 ,8987 ,8965 ,8872 ,8830 ,8780 ,8762 ,8681 ,8599 ,8578 ,8553 ,8523 ,8502 ,8459 ,8252 ,8246 ,8233 ,8208 ,7966 ,7957 ,7891 ,7889 ,7878 ,7831 ,7629 ,7452 ,7387 ,7236 ,7201 ,7177 ,7137 ,7079 ,6941 ,6796 ,6741 ,6679 ,6662 ,6637 ,6586 ,6410 ,6399 ,6356 ,6291 ,6199 ,6187 ,6148 ,6010 ,5904 ,5850 ,5650 ,5649 ,5622 ,5574 ,5517 ,5487 ,5361 ,5241 ,5219 ,5114 ,5107 ,5106 ,5073 ,5063 ,5008 ,4957 ,4926 ,4800 ,4735 ,4632 ,4624 ,4575 ,4483 ,4410 ,4408 ,4408 ,4397 ,4302 ,4297 ,4222 ,4076 ,3943 ,3870 ,3786 ,3682 ,3672 ,3577 ,3536 ,3372 ,3368 ,3352 ,3302 ,3287 ,3261 ,3229 ,3164 ,3096 ,3077 ,2926 ,2772 ,2770 ,2732 ,2649 ,2615 ,2565 ,2461 ,2325 ,2228 ,2076 ,2037 ,1936 ,1822 ,1635 ,1505 ,1455 ,1305 ,1246 ,1229 ,1175 ,1123 ,1065 ,1032 ,946 ,824 ,766 ,680 ,676 ,595 ,537 ,458 ,200 ,59 ,23 ,8 ,-238 ,-239 ,-362 ,-362 ,-369 ,-429 ,-443 ,-479 ,-501 ,-673 ,-702 ,-749 ,-796 ,-916 ,-1018 ,-1062 ,-1062 ,-1078 ,-1160 ,-1176 ,-1446 ,-1484 ,-1574 ,-1610 ,-1634 ,-1666 ,-1683 ,-1766 ,-1793 ,-1981 ,-1997 ,-2055 ,-2083 ,-2089 ,-2099 ,-2105 ,-2204 ,-2371 ,-2409 ,-2414 ,-2438 ,-2541 ,-2570 ,-2601 ,-2685 ,-2691 ,-2720 ,-2796 ,-2871 
,-2905 ,-2906 ,-2925 ,-2940 ,-2948 ,-2980 ,-3034 ,-3066 ,-3099 ,-3181 ,-3260 ,-3261 ,-3269 ,-3535 ,-3576 ,-3668 ,-3674 ,-3847 ,-3877 ,-4031 ,-4098 ,-4111 ,-4379 ,-4420 ,-4467 ,-4553 ,-4556 ,-4650 ,-4689 ,-4727 ,-4729 ,-4755 ,-4828 ,-5022 ,-5060 ,-5065 ,-5147 ,-5156 ,-5164 ,-5218 ,-5277 ,-5294 ,-5350 ,-5555 ,-5562 ,-5665 ,-5709 ,-5794 ,-5966 ,-5991 ,-6068 ,-6096 ,-6153 ,-6234 ,-6256 ,-6338 ,-6485 ,-6558 ,-6625 ,-6688 ,-6693 ,-6826 ,-6939 ,-6953 ,-7032 ,-7060 ,-7228 ,-7261 ,-7442 ,-7449 ,-7610 ,-7875 ,-7885 ,-7886 ,-7984 ,-8004 ,-8026 ,-8054 ,-8230 ,-8323 ,-8358 ,-8412 ,-8542 ,-8614 ,-8651 ,-8670 ,-8744 ,-8834 ,-8882 ,-8887 ,-9065 ,-9076 ,-9136 ,-9166 ,-9210 ,-9226 ,-9669 ,-9803 ,-9846 ,-9941 ,-9954 ,-9999 ,

Superado😅

Para quienes necesiten la cantidad de números en vector es este:
int vector[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595};

He utilizado el método burbuja / bubble sort, lo ordene en ascendente y descendente.

#include <stdio.h>

void change_position(int *n1, int *n2){
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void bubble_sort(int vector_in[], int n){
    int i, j;
    for (i = 0; i < n-1; i++){
        for (j = 0; j < n-i-1; j++)
        {
            if(vector_in[j] > vector_in[j+1]){
                change_position(&vector_in[j], &vector_in[j+1]);
            }
        }
    }
}

void bubble_sort_reverse(int vector_in[], int n){
    int i, j;
    for (i = 0; i < n-1; i++){
        for (j = 0; j < n-i-1; j++)
        {
            if(vector_in[j] < vector_in[j+1]){
                change_position(&vector_in[j], &vector_in[j+1]);
            }
        }
    }
}

int print(int vector_in[], int n){
    int i;
    for (i = 0; i < n; i++){
        printf("%d ,", vector_in[i]);
    }

    printf("\n Fin del Ordenamiento\n");
}

int main(int argc, char const *argv[])
{
    int vector_main[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595};
    int n = sizeof(vector_main)/sizeof(vector_main[0]);
    printf("Vector Original\n");
    print(vector_main, n);
    printf("\n");
    printf("Vector Order Asc\n");
    bubble_sort(vector_main, n);
    print(vector_main, n);
    printf("\n");
    printf("Vector Order Des\n");
    bubble_sort_reverse(vector_main, n);
    print(vector_main, n);
    printf("\n");

    return 0;
}
#include <iostream>
#include <fstream>
#include <stdlib.h>

using namespace std;

void insertionsort(int numlist[300], int n){
    int current_value, j;
    for(int i=1; i<n; i++){
        current_value = numlist[i];
        j = i-1;
        while(numlist[j] > current_value && j >= 0){
            numlist[j+1] = numlist[j];
            j--;
        }
        numlist[j+1] = current_value;
    }
}

int main()
{
    int n = 300;
    int numlist[300];
    string line;
    int i = 0;

    ifstream MyNums("nums.txt");

    while(getline(MyNums, line)){
        numlist[i] = atoi(line.c_str());
        i++;
    }

    MyNums.close();

    for(int i=0; i<300; i++){
        cout << numlist[i] << endl;
    }

    cout << "Lets sort------------------------------------------------"<< endl;
    insertionsort(numlist, n);

    for(int i=0; i<300; i++){
        cout << numlist[i] << endl;
    }

    return 0;

Debido a la gran cantidad de datos, decidi usar QuickSort en Javascript:

Y este es el resultado:

Y si son como yo, les paso una forma de como ser flojos (palabra en mexicano para hacer referencia a una persona que no le gusta trabajar y / o hacer trabajos repetitivos) para cambiar las " , " de un sentón (de una manera rápida, otra vez, en mexicano xd).

1.-Abren el inspector de elementos y seleccionan el elemento p, y le dan “copiar elemento”. Copien el elemento html en su totalidad que es el parrafo ( p ) que contiene todo el texto de los numeros.

2.- Después lo abren en su editor de texto (copien y pegan lo que copiaron en otras palabras)

3.- Utilizan el (en mi caso, visual studio code) ctrl +d para seleccionar todos los br (dejen presionado las teclas)

4.- Una vez que todos los br (saltos de linea) seleccionados, opriman la " , ". (No se les olvide borrar las etiquetas de p, al principio y al final)

GRACIAS CURSOS DE FRONTEND DE PLATZI 😃

Python, Bubble Sort de mayor a menor.

Reto cumplido con JavaScript.

function insertionSort(array) {
  let currentValue;
  let j;
  for (let i = 1; i < array.length; i++) {
    currentValue = array[i];

    j = i - 1;

    while (j >= 0 && array[j] < currentValue) {
      array[j + 1] = array[j];
      j--;
    }

    array[j + 1] = currentValue;
  }

  return array;
}
Os dejo codigo en Python: def ordenamiento\_burbuja(arr):     n = len(arr)    for i in range(n):        intercambio = False        for j in range(0, n-i-1):            if arr\[j] > arr\[j+1]:                arr\[j], arr\[j+1] = arr\[j+1], arr\[j]                intercambio = True        if not intercambio:            break numeros = \[-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887 ,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297 ,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099 ,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098 ,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448 ,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536 ,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624 ,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387 ,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762 ,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629 ,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875 ,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181 ,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541 ,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595] print("Lista original: ", numeros) ordenamiento\_burbuja(numeros) print("Lista ordenada: ",numeros) Saludos, @josecodetech
Algoritmo quicksort implementado en Bash: `# !/bin/bash` `# Algoritmo de ordenamiento quicksort o divide y vence` `quicksort() {` ` local pivot i smaller=() larger=()` ` if (($# == 0)); then` ` echo` ` return` ` fi` ` pivot=$1` ` #i=$@` ` # El comando shift va a eliminar el primer argumento pasado a la funcion, ya que lo tomamos como punto de pivote` ` shift` ` # El bucle for va a tomar uno a uno los valores pasados como argumento, no es necesario hacer: "i=$@" ya que,` ` # se inicializa automaticamente en cada uno de los argumentos pasados como argumento` ` # Va a ir dividiendo los valores en los dos arrays dependiendo del punto de pivote y asi recursivamente hasta ordenarlos.` ` for i; do` ` if ((i < pivot)); then` ` smaller+=( "$i" )` ` else` ` larger+=( "$i" )` ` fi` ` done` ` quicksort "${smaller[@]}"` ` printf '%d ' "$pivot"` ` quicksort "${larger[@]}"` `}` `quicksort 1 2 8 3 9 5 7 4 6` Claramente, este script de bash es más lento que la utilidad "sort" de Linux, ya que está escrita en "C" y más optimizado.
Bash result: `cat ordenar.txt | sort -n | xargs | tr " " ","` `-9999,-9954,-9941,-9846,-9803,-9669,-9226,-9210,-9166,-9136,-9076,-9065,-8887,-8882,-8834,-8744,-8670,-8651,-8614,-8542,-8412,-8358,-8323,-8230,-8054,-8026,-8004,-7984,-7886,-7885,-7875,-7610,-7449,-7442,-7261,-7228,-7060,-7032,-6953,-6939,-6826,-6693,-6688,-6625,-6558,-6485,-6338,-6256,-6234,-6153,-6096,-6068,-5991,-5966,-5794,-5709,-5665,-5562,-5555,-5350,-5294,-5277,-5218,-5164,-5156,-5147,-5065,-5060,-5022,-4828,-4755,-4729,-4727,-4689,-4650,-4556,-4553,-4467,-4420,-4379,-4111,-4098,-4031,-3877,-3847,-3674,-3668,-3576,-3535,-3269,-3261,-3260,-3181,-3099,-3066,-3034,-2980,-2948,-2940,-2925,-2906,-2905,-2871,-2796,-2720,-2691,-2685,-2601,-2570,-2541,-2438,-2414,-2409,-2371,-2204,-2105,-2099,-2089,-2083,-2055,-1997,-1981,-1793,-1766,-1683,-1666,-1634,-1610,-1574,-1484,-1446,-1176,-1160,-1078,-1062,-1062,-1018,-916,-796,-749,-702,-673,-501,-479,-443,-429,-369,-362,-362,-239,-238,8,23,59,200,458,537,595,676,680,766,824,946,1032,1065,1123,1175,1229,1246,1305,1455,1505,1635,1822,1936,2037,2076,2228,2325,2461,2565,2615,2649,2732,2770,2772,2926,3077,3096,3164,3229,3261,3287,3302,3352,3368,3372,3536,3577,3672,3682,3786,3870,3943,4076,4222,4297,4302,4397,4408,4408,4410,4483,4575,4624,4632,4735,4800,4926,4957,5008,5063,5073,5106,5107,5114,5219,5241,5361,5487,5517,5574,5622,5649,5650,5850,5904,6010,6148,6187,6199,6291,6356,6399,6410,6586,6637,6662,6679,6741,6796,6941,7079,7137,7177,7201,7236,7387,7452,7629,7831,7878,7889,7891,7957,7966,8208,8233,8246,8252,8459,8502,8523,8553,8578,8599,8681,8762,8780,8830,8872,8965,8987,9131,9162,9222,9254,9329,9421,9448,9497,9521,9545,9551,9622,9720,9791,9883,9885,9976`

public class BubbleSort {

public static void main(String[] args) {
    int[] array = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887

,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297
,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099
,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098
,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448
,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536
,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624
,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387
,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762
,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629
,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875
,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181
,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541
,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};

    System.out.println("Array original:");
    printArray(array);
    
    bubbleSort(array);
    
    System.out.println("Array ordenado:");
    printArray(array);
}

public static void bubbleSort(int[] arr) {
    int n = arr.length;
    boolean swapped;
    do {
        swapped = false;
        for (int i = 1; i < n; i++) {
            if (arr[i - 1] > arr[i]) {
                // Intercambia arr[i-1] y arr[i]
                int temp = arr[i - 1];
                arr[i - 1] = arr[i];
                arr[i] = temp;
                swapped = true;
            }
        }
    } while (swapped);
}

public static void printArray(int[] arr) {
    for (int num : arr) {
        System.out.print(num + " ");
    }
    System.out.println();
}

}

const arr = [
  -796,
  3229,
  -5164,
  -362,
  4408,
  8965,
  -6068,
  9329,
  -3034,
  -443,
  -6693,
  9497,
  2615,
  -5966,
  -9065,
  -1160,
  6148,
  5517,
  1123,
  -8887,
  5649,
  3302,
  -1176,
  -8542,
  -9166,
  8,
  -2906,
  8987,
  -2414,
  -7984,
  4410,
  8872,
  5241,
  -4556,
  59,
  -5562,
  -3877,
  7452,
  -4467,
  2076,
  4076,
  4297,
  -3847,
  -2055,
  4483,
  -1484,
  -2371,
  6199,
  -7261,
  -7032,
  6010,
  2325,
  -6625,
  -2601,
  3870,
  1822,
  -5665,
  9622,
  9883,
  -5794,
  -5218,
  2926,
  8599,
  -3099,
  6399,
  -2570,
  3943,
  -2409,
  5114,
  9791,
  -4420,
  1065,
  3077,
  -1062,
  -8004,
  4397,
  1635,
  8578,
  -9226,
  9222,
  -1793,
  -2691,
  -5060,
  -4727,
  -4098,
  946,
  ,
  -6558,
  -4111,
  4575,
  -2685,
  -4729,
  -5277,
  1936,
  5106,
  -2089,
  824,
  9421,
  -1683,
  -2083,
  7891,
  -2099,
  1305,
  -9076,
  -3535,
  2565,
  -2871,
  9448,
  7177,
  -8614,
  -9954,
  -362,
  1455,
  -8834,
  -9846,
  -8412,
  1175,
  -1981,
  -5991,
  7201,
  -1997,
  -5156,
  -1634,
  -9803,
  1032,
  9551,
  -6153,
  8502,
  3536,
  -2980,
  8681,
  -9210,
  4408,
  8780,
  -916,
  -369,
  -8651,
  1246,
  -702,
  -5555,
  23,
  8208,
  2037,
  6941,
  9545,
  -5147,
  5063,
  -8358,
  2772,
  8553,
  9885,
  4624,
  -3576,
  9131,
  1229,
  -429,
  -479,
  -673,
  -7060,
  -4031,
  5650,
  6679,
  6796,
  5622,
  -6256,
  -238,
  -6096,
  3096,
  -1610,
  -2948,
  6291,
  -1666,
  5219,
  5850,
  7387,
  -3260,
  3672,
  -1766,
  -9941,
  8252,
  2649,
  7079,
  -8026,
  6356,
  676,
  -5065,
  -6338,
  3287,
  680,
  -3269,
  2770,
  6637,
  -8744,
  9162,
  -2204,
  -3066,
  -7228,
  8762,
  1505,
  4957,
  766,
  -9136,
  4632,
  -5022,
  -9999,
  5361,
  2732,
  7831,
  -501,
  -4650,
  7236,
  3682,
  -2438,
  5574,
  -8230,
  -9669,
  -7442,
  7966,
  -2905,
  7629,
  7137,
  200,
  -8670,
  -749,
  2228,
  458,
  7889,
  -3668,
  -5350,
  -3261,
  6741,
  -6953,
  4800,
  3372,
  6662,
  -1018,
  8523,
  3164,
  3577,
  9720,
  -6826,
  -1574,
  -7875,
  -2796,
  -1078,
  -4755,
  4926,
  3368,
  4302,
  9254,
  6410,
  -4689,
  7878,
  2461,
  8233,
  -6688,
  5904,
  4735,
  -2940,
  8830,
  9976,
  -3674,
  4222,
  -1446,
  6187,
  -3181,
  -8882,
  5487,
  -6939,
  -7885,
  3786,
  -6234,
  -1062,
  -4553,
  -5709,
  8459,
  5008,
  3352,
  6586,
  537,
  -7610,
  3261,
  8246,
  -2105,
  5107,
  7957,
  -7886,
  -2925,
  -2541,
  -7449,
  9521,
  5073,
  -239,
  -8054,
  -4379,
  -8323,
  -6485,
  -4828,
  -5294,
  -2720,
  595,
];

const compareDescending = (a, b) => b - a;

arr.sort(compareDescending);

console.log(arr);

Ordenamiento con Quick Sort y Python

def quickSort(arr):
    if len(arr) <= 1:
        return arr

    else:
        #Se elige el primer elemento como pivote
        pivot = arr[0]
        #Se crean dos sublistas utilizando comprensiones de lista
        # - 'less' contiene los elementos menores o iguales al pivote
        # - 'greater' contiene los elementos mayores al pivote

        less = [x for x in arr[1:] if x <= pivot]
        greater = [x for x in arr[1:] if x > pivot]

        #Se aplica recursivamente quick_sort a las sublistas 'less' y 'greater'
        return quickSort(less) + [pivot] + quickSort(greater)
    

#Ejemplo de uso
array = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887
,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297
,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099
,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098
,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448
,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536
,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624
,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387
,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762
,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629
,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875
,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181
,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541
,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595]

sorted_array = quickSort(array)
print(sorted_array)

Applying Bubble Sort in Python:

Hasta que no entendí cada parte del código no descanse XD. Es demasiado util el print statement.

Se demoro 2ms ⌚ más que Insert Sort

Challenge in Python:

  1. guarde los datos como .csv
  2. Use la librería csv para abrir el archivo.
  3. Implemente método Insert Sort, aunque bastaría con sorted() para ordenarlos. También la haré con bubble sort para comparar y practicar.

Explicación del código

  1. Comenzamos inicializando tres variables: i, current, j.
    • i almacena el último índice iterado de izquierda a derecha.
    • current almacena el último elemento iterado de izquierda a derecha (utiliza i como herramienta).
    • j representa el valor de iteración de derecha a izquierda, desde el índice i hasta el índice -1 del arreglo.
  2. A partir de la última declaración, podemos decir que tenemos dos bucles, uno de izquierda a derecha y, dentro de él, uno de derecha a izquierda.
    • En el bucle interno, verificamos dos cosas:
      • Que j no sea -1.
      • Que el elemento en la posición j (recuerda, de derecha a izquierda) sea mayor que i.
    • Si la condición es verdadera en el bucle interno (es decir, el elemento j es mayor que el elemento i):
      • Movemos cada elemento desde j + 1 hasta i un espacio a la derecha para que i pueda caber en j + 1 (debe ser j + 1 porque desde el final de la ejecución del bucle interno, j está un índice por debajo del espacio vacío necesario para i).
  3. Repetimos este proceso hasta que i alcance n.

Les comparto mi solución.

// Custom Sort Algorithm
#include<stdio.h>
#include<stdlib.h>
// De Mayor a Menor
void custom_sort(int vector_entrada[],int n)
{
    int i, i2, i3, i4;
    int length = n;
    int* new_array = (int*)malloc(n * sizeof(int));
    int* indexes_array = (int*)malloc(n * sizeof(int));
        
    for(i=0;i<=n-1;i++)
    {
        // Elegimos el elemento de esta repetición
        int current_element = vector_entrada[i];
        int current_element_index = 0;
        // Comparamos este elemento con todos los elementos
        
        for(i2=0;i2<=n-1;i2++)
        {
            // Elegimos el elemento con el cual se va comparar
            int comparison_element =vector_entrada[i2];
            if(current_element<comparison_element){
                // Si el elemento actual es menor vamos desplazando su indice hacia el final
                current_element_index++;
            }
        }
        indexes_array[i] = current_element_index;
    }
    // finalmente, ubicamos cada elemento del array original
    // en su indice respectivo del array ordenado
    for(i3=0;i3<=n-1;i3++)
    {
        new_array[indexes_array[i3]] = vector_entrada[i3];
    }
    //Copiamos los valores ordenados a nuestro array origianal
    for(i4=0;i4<=n-1;i4++)
    {
        vector_entrada[i4] =  new_array[i4];
    }
    free(new_array);       // Free dynamically allocated memory
    free(indexes_array);   // Free dynamically allocated memory
}

int print_array(int vector_entrada[], int n)
{
    int i;
    for(i=0; i<=n-1;i++)
        printf("%d ", vector_entrada[i]);
    printf("\n");
}

main(int argc, char const *argv[])
{
// Insertar los valores que se deseen probar dentro de los corchetes
    int test_array[]={-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615};
    int n = sizeof(test_array)/sizeof(test_array[0]);
    printf("Array inicial: \n");
    print_array(test_array, n);
    custom_sort(test_array, n);
    printf("Array ordenado de mayor a menor: \n");
    print_array(test_array, n);
    return 0;
}

Aqui dejo mi aporte en python usando selection sort:

#find the smallest value
def findSmallest(arr) :
    smallest = arr[0]
    smallest_index = 0

    for i in range(1, len(arr)):
        if arr[i] < smallest:
            smallest = arr[i]
            smallest_index = i
    return smallest_index

def selectionSort(arr):
    newArr = []
    for i in range(len(arr)):
        smallest = findSmallest(arr)
        newArr.append(arr.pop(smallest))
    return newArr

print(selectionSort([
    -796,
3229,
-5164,
-362,
4408,
8965,
-6068,
9329,
-3034,
-443,
-6693,
9497,
2615,
-5966,
-9065,
-1160,
6148,
5517,
1123,
-8887,
5649,
3302,
-1176,
-8542,
-9166,
8,
-2906,
8987,
-2414,
-7984,
4410,
8872,
5241,
-4556,
59,
-5562,
-3877,
7452,
-4467,
2076,
4076,
4297,
-3847,
-2055,
4483,
-1484,
-2371,
6199,
-7261,
-7032,
6010,
2325,
-6625,
-2601,
3870,
1822,
-5665,
9622,
9883,
-5794,
-5218,
2926,
8599,
-3099,
6399,
-2570,
3943,
-2409,
5114,
9791,
-4420,
1065,
3077,
-1062,
-8004,
4397,
1635,
8578,
-9226,
9222,
-1793,
-2691,
-5060,
-4727,
-4098,
946,
-6558,
-4111,
4575,
-2685,
-4729,
-5277,
1936,
5106,
-2089,
824,
9421,
-1683,
-2083,
7891,
-2099,
1305,
-9076,
-3535,
2565,
-2871,
9448,
7177,
-8614,
-9954,
-362,
1455,
-8834,
-9846,
-8412,
1175,
-1981,
-5991,
7201,
-1997,
-5156,
-1634,
-9803,
1032,
9551,
-6153,
8502,
3536,
-2980,
8681,
-9210,
4408,
8780,
-916,
-369,
-8651,
1246,
-702,
-5555,
23,
8208,
2037,
6941,
9545,
-5147,
5063,
-8358,
2772,
8553,
9885,
4624,
-3576,
9131,
1229,
-429,
-479,
-673,
-7060,
-4031,
5650,
6679,
6796,
5622,
-6256,
-238,
-6096,
3096,
-1610,
-2948,
6291,
-1666,
5219,
5850,
7387,
-3260,
3672,
-1766,
-9941,
8252,
2649,
7079,
-8026,
6356,
676,
-5065,
-6338,
3287,
680,
-3269,
2770,
6637,
-8744,
9162,
-2204,
-3066,
-7228,
8762,
1505,
4957,
766,
-9136,
4632,
-5022,
-9999,
5361,
2732,
7831,
-501,
-4650,
7236,
3682,
-2438,
5574,
-8230,
-9669,
-7442,
7966,
-2905,
7629,
7137,
200,
-8670,
-749,
2228,
458,
7889,
-3668,
-5350,
-3261,
6741,
-6953,
4800,
3372,
6662,
-1018,
8523,
3164,
3577,
9720,
-6826,
-1574,
-7875,
-2796,
-1078,
-4755,
4926,
3368,
4302,
9254,
6410,
-4689,
7878,
2461,
8233,
-6688,
5904,
4735,
-2940,
8830,
9976,
-3674,
4222,
-1446,
6187,
-3181,
-8882,
5487,
-6939,
-7885,
3786,
-6234,
-1062,
-4553,
-5709,
8459,
5008,
3352,
6586,
537,
-7610,
3261,
8246,
-2105,
5107,
7957,
-7886,
-2925,
-2541,
-7449,
9521,
5073,
-239,
-8054,
-4379,
-8323,
-6485,
-4828,
-5294,
-2720,
595
]))

Implementé Merge sort en Python, este es el código resultante:

def merge(left_arr, right_arr):
    result = []

    while len(left_arr) > 0 and len(right_arr) > 0:
        if (left_arr[0] < right_arr[0]):
            result.append(left_arr.pop(0))
        else:
            result.append(right_arr.pop(0))

    result.extend(left_arr)
    result.extend(right_arr)
    return result

def merge_sort(arr):
    size = len(arr)

    if size <= 1:
        return arr

    middle = size // 2
    left_arr = merge_sort(arr[:middle])
    right_arr = merge_sort(arr[middle:])
    return merge(left_arr, right_arr)

Este es el codigo para ordenarlos en Java

public class Main {

    public static void insertionSort(int arr[], int n){
        int currentVal, j;
        for (int i = 1; i < n; i++) {
            currentVal = arr[i];
            j =i-1;
            while(j >=0 && arr[j] > currentVal){
                arr[j+1] = arr[j];
                j = j-1;
            }
            arr[j+1] = currentVal;
        }
    }

    public static void printArray(int arr[], int n){
        for (int i = 0; i < n; i++)
            System.out.println(arr[i] + " ");
    }

    public static void main(String[] args) {
        int arr[] = {
                -796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887
                ,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297
                ,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099
                ,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098
                ,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448
                ,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536
                ,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624
                ,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387
                ,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762
                ,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629
                ,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875
                ,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181
                ,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541
                ,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595
        };

        int n = arr.length;

        insertionSort(arr, n);
        printArray(arr, n);
    }
}

Este es mi reto, es un algoritmo de insertion sort

include <stdio.h>

// Para cada valor del array verificar la distancia que hay entre él y el primer valor mayor a este.
// Si dicha distancia es mayor a 0 significa que el valor está antes que el valor actual
// Se guarda el valor actual y se recorren todos los valores que en la distanci una posición para atras y se coloca en valor guardado en el valor de la distancia
void insertionSort(int array[], int arraySize) {
    for (int i = 0; i < arraySize; i++) {
        int distancia = i;
        while(array[i] < array[i - distancia]) {
            distancia--;
        }
        if(distancia > 0) {
            int save = array[i];
            for(int j = 0; j < distancia; j++) {
                array[i - j] = array[i - j - 1];
            }
            array[i - distancia] = save;
        }
    }
}

void showArray(int array[], int arraySize) {
    for(int i = 0; i < arraySize; i++)
        printf("%d, ", array[i]);
}

int main() {
    int n;
    int arrayNumbers[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887
        ,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297
        ,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099
        ,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098
        ,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448
        ,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536
        ,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624
        ,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387
        ,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762
        ,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629
        ,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875
        ,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181
        ,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541
        ,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};

    n = sizeof(arrayNumbers) / sizeof(arrayNumbers[0]);
    insertionSort(arrayNumbers, n);
    showArray(arrayNumbers, n);

    return 0;
}

Mi aporte con Javascritpt
Saludos

Como siempre el querido Python3.9 hace un mergesort que es una maravilla:

def merge_sort(lista):
    if len(lista) > 1:
        half = len(lista) // 2
        first_half = lista[:half]
        second_half = lista[half:]

        merge_sort(first_half)
        merge_sort(second_half)
        n = 0
        m = 0
        p = 0

        while n < len(first_half) and m < len(second_half):
            if first_half[n] > second_half[m]:
                lista[p] = first_half[n]
                n += 1
            else:
                lista[p] = second_half[m]
                m += 1
            p += 1

        while n < len(first_half):
            lista[p] = first_half[n]
            n += 1
            p += 1

        while m < len(second_half):
            lista[p] = second_half[m]
            m += 1
            p += 1

numeros = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887
,5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297
,-3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099
,6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098
,946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448
,7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -515, -1634, -9803, 1032, 9551, -6153, 8502, 3536
,-2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624
,-3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387
,-3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762
,1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629
,7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875
,-2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181
,-8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541
,-7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595]

print(numeros)

merge_sort(numeros)
print(numeros)

Imprime las dos listas de números. La original y la ordenada de mayor a menor.

Este es el vector ordenado:
[9976, 9885, 9883, 9791, 9720, 9622, 9551, 9545, 9521, 9497, 9448, 9421, 9329, 9254, 9222, 9162, 9131, 8987, 8965, 8872, 8830, 8780, 8762, 8681, 8599, 8578, 8553, 8523, 8502, 8459, 8252, 8246, 8233, 8208, 7966, 7957, 7891, 7889, 7878, 7831, 7629, 7452, 7387, 7236, 7201, 7177, 7137, 7079, 6941, 6796, 6741, 6679, 6662, 6637, 6586, 6410, 6399, 6356, 6291, 6199, 6187, 6148, 6010, 5904, 5850, 5650, 5649, 5622, 5574, 5517, 5487, 5361, 5241, 5219, 5114, 5107, 5106, 5073, 5063, 5008, 4957, 4926, 4800, 4735, 4632, 4624, 4575, 4483, 4410, 4408, 4408, 4397, 4302, 4297, 4222, 4076, 3943, 3870, 3786, 3682, 3672, 3577, 3536, 3372, 3368, 3352, 3302, 3287, 3261, 3229, 3164, 3096, 3077, 2926, 2772, 2770, 2732, 2649, 2615, 2565, 2461, 2325, 2228, 2076, 2037, 1936, 1822, 1635, 1505, 1455, 1305, 1246, 1229, 1175, 1123, 1065, 1032, 946, 824, 766, 680, 676, 595, 537, 458, 200, 59, 23, 8, -238, -239, -362, -362, -369, -429, -443, -479, -501, -673, -702, -749, -796, -916, -1018, -1062, -1062, -1078, -1160, -1176, -1446, -1484, -1574, -1610, -1634, -1666, -1683, -1766, -1793, -1981, -1997, -2055, -2083, -2089, -2099, -2105, -2204, -2371, -2409, -2414, -2438, -2541, -2570, -2601, -2685, -2691, -2720, -2796, -2871, -2905, -2906, -2925, -2940, -2948, -2980, -3034, -3066, -3099, -3181, -3260, -3261, -3269, -3535, -3576, -3668, -3674, -3847, -3877, -4031, -4098, -4111, -4379, -4420, -4467, -4553, -4556, -4650, -4689, -4727, -4729, -4755, -4828, -5022, -5060, -5065, -5147, -5156, -5164, -5218, -5277, -5294, -5350, -5555, -5562, -5665, -5709, -5794, -5966, -5991, -6068, -6096, -6153, -6234, -6256, -6338, -6485, -6558, -6625, -6688, -6693, -6826, -6939, -6953, -7032, -7060, -7228, -7261, -7442, -7449, -7610, -7875, -7885, -7886, -7984, -8004, -8026, -8054, -8230, -8323, -8358, -8412, -8542, -8614, -8651, -8670, -8744, -8834, -8882, -8887, -9065, -9076, -9136, -9166, -9210, -9226, -9669, -9803, -9846, -9941, -9954, -9999]

Con Python:
def crear_arreglo():
vector_entrada = [-796 ,
3229 ,
-5164 ,
-362 ,
4408 ,
8965 ,
-6068 ,
9329 ,
-3034 ,
-443 ,
-6693 ,
9497 ,
2615 ,
-5966 ,
-9065 ,
-1160 ,
6148 ,
5517 ,
1123 ,
-8887 ,
5649 ,
3302 ,
-1176 ,
-8542 ,
-9166 ,
8 ,
-2906 ,
8987 ,
-2414 ,
-7984 ,
4410 ,
8872 ,
5241 ,
-4556 ,
59 ,
-5562 ,
-3877 ,
7452 ,
-4467 ,
2076 ,
4076 ,
4297 ,
-3847 ,
-2055 ,
4483 ,
-1484 ,
-2371 ,
6199 ,
-7261 ,
-7032 ,
6010 ,
2325 ,
-6625 ,
-2601 ,
3870 ,
1822 ,
-5665 ,
9622 ,
9883 ,
-5794 ,
-5218 ,
2926 ,
8599 ,
-3099 ,
6399 ,
-2570 ,
3943 ,
-2409 ,
5114 ,
9791 ,
-4420 ,
1065 ,
3077 ,
-1062 ,
-8004 ,
4397 ,
1635 ,
8578 ,
-9226 ,
9222 ,
-1793 ,
-2691 ,
-5060 ,
-4727 ,
-4098 ,
946 ,
-6558 ,
-4111 ,
4575 ,
-2685 ,
-4729 ,
-5277 ,
1936 ,
5106 ,
-2089 ,
824 ,
9421 ,
-1683 ,
-2083 ,
7891 ,
-2099 ,
1305 ,
-9076 ,
-3535 ,
2565 ,
-2871 ,
9448 ,
7177 ,
-8614 ,
-9954 ,
-362 ,
1455 ,
-8834 ,
-9846 ,
-8412 ,
1175 ,
-1981 ,
-5991 ,
7201 ,
-1997 ,
-5156 ,
-1634 ,
-9803 ,
1032 ,
9551 ,
-6153 ,
8502 ,
3536 ,
-2980 ,
8681 ,
-9210 ,
4408 ,
8780 ,
-916 ,
-369 ,
-8651 ,
1246 ,
-702 ,
-5555 ,
23 ,
8208 ,
2037 ,
6941 ,
9545 ,
-5147 ,
5063 ,
-8358 ,
2772 ,
8553 ,
9885 ,
4624 ,
-3576 ,
9131 ,
1229 ,
-429 ,
-479 ,
-673 ,
-7060 ,
-4031 ,
5650 ,
6679 ,
6796 ,
5622 ,
-6256 ,
-238 ,
-6096 ,
3096 ,
-1610 ,
-2948 ,
6291 ,
-1666 ,
5219 ,
5850 ,
7387 ,
-3260 ,
3672 ,
-1766 ,
-9941 ,
8252 ,
2649 ,
7079 ,
-8026 ,
6356 ,
676 ,
-5065 ,
-6338 ,
3287 ,
680 ,
-3269 ,
2770 ,
6637 ,
-8744 ,
9162 ,
-2204 ,
-3066 ,
-7228 ,
8762 ,
1505 ,
4957 ,
766 ,
-9136 ,
4632 ,
-5022 ,
-9999 ,
5361 ,
2732 ,
7831 ,
-501 ,
-4650 ,
7236 ,
3682 ,
-2438 ,
5574 ,
-8230 ,
-9669 ,
-7442 ,
7966 ,
-2905 ,
7629 ,
7137 ,
200 ,
-8670 ,
-749 ,
2228 ,
458 ,
7889 ,
-3668 ,
-5350 ,
-3261 ,
6741 ,
-6953 ,
4800 ,
3372 ,
6662 ,
-1018 ,
8523 ,
3164 ,
3577 ,
9720 ,
-6826 ,
-1574 ,
-7875 ,
-2796 ,
-1078 ,
-4755 ,
4926 ,
3368 ,
4302 ,
9254 ,
6410 ,
-4689 ,
7878 ,
2461 ,
8233 ,
-6688 ,
5904 ,
4735 ,
-2940 ,
8830 ,
9976 ,
-3674 ,
4222 ,
-1446 ,
6187 ,
-3181 ,
-8882 ,
5487 ,
-6939 ,
-7885 ,
3786 ,
-6234 ,
-1062 ,
-4553 ,
-5709 ,
8459 ,
5008 ,
3352 ,
6586 ,
537 ,
-7610 ,
3261 ,
8246 ,
-2105 ,
5107 ,
7957 ,
-7886 ,
-2925 ,
-2541 ,
-7449 ,
9521 ,
5073 ,
-239 ,
-8054 ,
-4379 ,
-8323 ,
-6485 ,
-4828 ,
-5294 ,
-2720 ,
595]
print('Este es el vector de entrada: ')
print(vector_entrada)
return vector_entrada

def insert_sort(vector):
n=len(vector)
for i in range(1,n):
actual = vector[i]
j=i
while j > 0 and vector[j-1]< actual:
vector[j]= vector[j-1]
j= j-1
vector[j]= actual
#print(vector)
return vector

def main():
vector_entrada=crear_arreglo()
vector_ordenado=insert_sort(vector_entrada)
print(’’)
print(’’)
print('Este es el vector ordenado: '.format(vector_ordenado))
print(vector_ordenado)

if name== ‘main’:
main()

Quicksort en C:

#include <stdio.h>

void swap(int *, int *);
void quickSort(int[], int, int);
int partition(int[], int, int);
void printVector(int[], int);

int main(int argc, const char *argv)
{
    int vector[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034,
    -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123,
    -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414,
    -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467,
    2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261,
    -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883,
    -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114,
    9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
    9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575,
    -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083,
    7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614,
    -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201,
    -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980,
    8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555,
    23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
    4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
    6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
    -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
    7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
    6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
    -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 
    3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 
    200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, 
    -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, 
    -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410,
    -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, 
    -3674, 4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786,
    -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 
    3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 
    5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};
    int n = sizeof(vector) / sizeof(vector[0]);

    quickSort(vector, 0, n - 1);
    printVector(vector, n);

    return 0;
}

void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void quickSort(int vector[], int low, int high)
{
    if (low < high)
    {
        int p = partition(vector, low, high);

        quickSort(vector, low, p - 1);
        quickSort(vector, p + 1, high);
    }
    
}

int partition(int vector[], int low, int high)
{
    int p = vector[high];
    int i = low - 1;

    for (int j = low; j < high; j++)
    {
        if (vector[j] < p)
        {
            i++;
            swap(&vector[i], &vector[j]);
        }
    }

    swap(&vector[i + 1], &vector[high]);
    return i + 1;
}

void printVector(int vector[], int n)
{
    for (int i = 0; i < n; i++)
        printf("%d ", vector[i]);

    printf("\n");
}

Salida:

-9999 -9954 -9941 -9846 -9803 -9669 -9226 -9210 -9166 -9136 -9076 -9065 -8887 -8882 -8834 -8744 -8670 -8651 -8614 -8542 -8412 -8358 -8323 -8230 -8054 -8026 -8004 -7984 -7886 -7885 -7875 -7610 -7449 -7442 -7261 -7228 -7060 -7032 -6953 -6939 -6826 -6693 -6688 -6625 -6558 -6485 -6338 -6256 -6234 -6153 -6096 -6068 -5991 -5966 -5794 -5709 -5665 -5562 -5555 -5350 -5294 -5277 -5218 -5164 -5156 -5147 -5065 -5060 -5022 -4828 
-4755 -4729 -4727 -4689 -4650 -4556 -4553 -4467 -4420 -4379 -4111 -4098 -4031 -3877 -3847 -3674 -3668 -3576 -3535 -3269 -3261 -3260 -3181 -3099 -3066 -3034 -2980 -2948 -2940 -2925 -2906 -2905 -2871 -2796 -2720 -2691 -2685 -2601 -2570 -2541 -2438 -2414 -2409 -2371 -2204 -2105 -2099 -2089 -2083 -2055 -1997 -1981 -1793 -1766 -1683 -1666 -1634 -1610 -1574 -1484 -1446 -1176 -1160 -1078 -1062 -1062 -1018 -916 -796 -749 -702 -673 -501 -479 -443 -429 -369 -362 -362 -239 -238 8 23 59 200 458 537 595 676 680 766 824 946 1032 1065 1123 1175 1229 1246 1305 1455 1505 1635 1822 1936 2037 2076 2228 2325 2461 2565 2615 2649 2732 2770 2772 2926 3077 3096 3164 3229 3261 3287 3302 3352 3368 3372 3536 3577 3672 3682 3786 3870 3943 4076 4222 4297 4302 4397 4408 4408 4410 4483 4575 4624 4632 4735 4800 4926 4957 5008 5063 5073 5106 5107 5114 5219 5241 5361 5487 5517 5574 5622 5649 5650 5850 5904 6010 6148 6187 6199 6291 6356 6399 6410 6586 6637 6662 6679 6741 6796 6941 7079 7137 7177 7201 7236 7387 7452 7629 7831 7878 7889 7891 7957 7966 8208 8233 8246 8252 8459 8502 8523 8553 8578 8599 8681 8762 8780 8830 8872 8965 8987 9131 9162 9222 9254 9329 9421 9448 9497 9521 9545 9551 9622 9720 9791 9883 9885 9976

Aquí mi solución: https://paiza.io/projects/GjMREq4sPwHdOInch4GgBw?language=c


#include <stdbool.h> 
#include<stdio.h>
void cambiar_pos(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void bubbleSort(int vector_entrada[], int n, bool order)
{
    int i, j;
    for(i=0; i < n-1; i++)
    {
        for(j=0; j < n-i-1; j++)
        {
            //[10, 5, 3, 3333]
            //order is true
            if(order){
                if(vector_entrada[j]>vector_entrada[j+1])
                    cambiar_pos(&vector_entrada[j],&vector_entrada[j+1]);
            }else{//order is false
                if(vector_entrada[j]<vector_entrada[j+1])
                    cambiar_pos(&vector_entrada[j],&vector_entrada[j+1]);
            }
        }
    }
}

int print_array(int vector_entrada[], int n)
{
    int i;
    for(i=0; i<n; i++)
        printf("%d ,", vector_entrada[i]);
    printf("\n fin del ordenamiento\n");
}

main(int argc, char const *argv[])
{
    int vector_entrada[]={-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595};
    //int vector_entrada2[] = vector_entrada;
    int n = sizeof(vector_entrada)/sizeof(vector_entrada[0]);
    
    bubbleSort(vector_entrada, n, false);//false order to desc
    print_array(vector_entrada, n);
    printf("\n");
    return 0;
}

En python con Quick Sort:

# Quick Sort algorithm in Python
# From lowest to highest

def partition(list, low, high):
    pivot = list[high]
    i = low - 1

    for j in range(low, high):
        if list[j] <= pivot:
            i += 1
            list[i], list[j] = list[j], list[i]

    list[i + 1], list[high] = list[high], list[i + 1]
    return i + 1

def quick_sort(list, low, high):
    if low < high:
        pi = partition(list, low, high)
        quick_sort(list, low, pi - 1)
        quick_sort(list, pi + 1, high)

def run():
    list = [-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034,
    -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123,
    -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414,
    -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467,
    2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261,
    -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883,
    -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114,
    9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
    9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575,
    -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083,
    7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614,
    -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201,
    -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980,
    8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555,
    23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885,
    4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650,
    6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291,
    -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649,
    7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770,
    6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766,
    -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 
    3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 
    200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, 
    -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, 
    -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410,
    -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, 
    -3674, 4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786,
    -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 
    3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 
    5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595, ]

    n = len(list)
    quick_sort(list, 0, n - 1)
    print(list)

if __name__ == "__main__":
    run()```

Mi codigo en c.

#include <stdio.h> 
#include <time.h>
  
/* Función de insertion Sort*/
void insertionSort(int vector[], int n) 
{ 
   int i, currentVal, j; 
   for (i = 1; i < n; i++) 
   { 
       currentVal= vector[i]; //obtenemos el valor actual a comparar
       j = i-1;
  
       /* mueve los elementos del arreglo vector[0..i-1],que son mayores que el valor de la posición actual del recorrido, a una posición adelante de su posición actual */
       while (j >= 0 && vector[j] > currentVal) 
       { 
           vector[j+1] = vector[j]; 
           j = j-1; 
       } 
       vector[j+1] = currentVal; 
   } 
} 

void change(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void bubbleSort(int 
vector_entrada[], int n)
{
    int i, j;
    for(i=0; i < n-1; i++)
    {
        for(j=0; j < n-i-1; j++)
        {
            //[10, 5, 3, 3333]
            if(vector_entrada[j]>vector_entrada[j+1])
            change(&vector_entrada[j],&vector_entrada[j+1]);
        }
    }
}
  
// función auxiliar para imprimir un arrary de tamaño n 
void printArray(int vector[], int n) 
{ 
   int i; 
   for (i=0; i < n; i++) 
       printf("%d, ", vector[i]); 
   printf("\n"); 
} 
  
  
  
/* Driver program to test insertion sort */
int main() 
{ 
    int vector[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595}; 
    int n = sizeof(vector)/sizeof(vector[0]); 
    clock_t start, end;
    double cpu_time_used;
    char option;
    do{        
        printf("[1] Algoritmo BubbleSort\n");
        printf("[2] Algoritmo InsertionSort\n");
        printf("[0] Salir\n");
        printf("Escoge un opcion: ");
        scanf("%c",&option);

        switch (option)
        {
        case '0': break;
        case '1':
            start = clock();
            bubbleSort(vector,n);
            end = clock();
            cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
            printArray(vector, n); 
            printf("Bubble Sort - Tiempo transcurrido %f seg.\n");
            break;
        case '2':
            start = clock();
            insertionSort(vector, n); 
            end = clock();
            cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
            printArray(vector, n); 
            printf("Insertion Sort - Tiempo transcurrido %f seg.\n");
            break;
        default:
            printf("Opción incorrecta.\n");
            break;
        } 
    }while (option!='0');
    
        
  
    return 0; 
} 

Utilicé el algoritmo de inserción en lenguaje C

<
#include <stdio.h>
#include <math.h>

void cambiarPosicion(int vector[], int pos)
{
  int aux;
  while (pos >= 0 && vector[pos] > vector[pos + 1])
  {
    aux = vector[pos];
    vector[pos] = vector[pos + 1];
    vector[pos + 1] = aux;
    pos--;
  }
  // vector[0]=aux;
}

void insertionSort(int vector[], int n)
{
  int i;
  for (i = 0; i < n - 1; i++)
  {
    if (vector[i] > vector[i + 1])
    {
      cambiarPosicion(vector, i);
    }
  }
}

void imprime(int vector[], int n)
{
  int i;
  for (i = 0; i < n; i++)
  {
    printf("%d, ", vector[i]);
  }
}

int main(int argc, char const *argv[])
{
  int vector[] = {
      -796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693,
      9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542,
      -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452,
      -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010,
      2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099, 6399,
      -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
      9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277,
      1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871,
      9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
      -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916,
      -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553,
      9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256,
      -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941,
      8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162,
      -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501,
      -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670,
      -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164,
      3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
      7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882,
      5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261,
      8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323,
      -6485, -4828, -5294, -2720, 595};

  int n = sizeof(vector) / sizeof(vector[0]);
  insertionSort(vector, n);
  imprime(vector, n);

  return 0;
}
>

QuickSort en C

#include <stdio.h>

int partition(int array[],int start, int end)
{
    int pivot = array[end];
    int pIndex = start;
    int i;
    for(i=start; i<end; i++)
    {
        if(array[i]<=pivot)
        {
          int temp = array[i];
          array[i] = array[pIndex];
          array[pIndex] = temp;
          pIndex++; 
        }
    }
    int temp = array[pIndex];
    array[pIndex] = array[end];
    array[end] = temp;
    return pIndex;
}

void printArray(int array[],int n)
{
    int i;
    for(i=0; i<n; i++)
    {
        printf("%d, ",array[i]);
    }
    printf("\n");
}

void quicksort(int array[],int start, int end)
{
    if(start<end)
    {
        int pIndex = partition(array,start,end);
        quicksort(array,start,pIndex-1);
        quicksort(array,pIndex+1,end);
    }
}



int main(int argc, char const *argv[])
{
    int array[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,-6693,
  9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542,
  -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452,
  -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 
  2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099,6399,
  -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
  9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277,
  1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871,
  9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
  -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916,
  -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553,
  9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256,
  -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941,
  8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162,
  -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501,
  -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670,
  -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164,
  3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
  7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882,
  5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459,5008, 3352, 6586, 537, -7610, 3261,
  8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323,
  -6485, -4828, -5294, -2720, 595};
    int n = sizeof(array)/sizeof(array[0]);
    printArray(array,n);
    quicksort(array,0,n);
    printArray(array,n);
    return 0;
}

QuickSort en Java

package com.cesarJavaTest;


public class QuickSort {

    public int[] quickSort(int[] array,int start, int end)
    {
        if(start < end)
        {
            int pIndex = partition(array,start,end);
            quickSort(array,start,pIndex-1);
            quickSort(array,pIndex+1,end);
        }
        return array;
    }


    private int partition(int[] array, int start, int end)
    {
        int pivot = array[end];
        int pIndex = start;
        for(int i=start; i<end; i++)
        {
            if(array[i]<=pivot)
            {
                int temp = array[i];
                array[i] = array[pIndex];
                array[pIndex] = temp;
                pIndex++;
            }
        }
        int temp = array[pIndex];
        array[pIndex] = array[end];
        array[end] = temp;
        return pIndex;
    }

    public void printArray(int[] array)
    {
        for(int i=0; i<array.length; i++)
        {
            System.out.print(array[i] + ", ");
        }
        System.out.println("");
    }
}```

Implementado con Insertion Sort

#include <stdio.h>
#include <math.h>

void InsertionSort(int arr[], int n){
  int i, currentVal, j;
  for(i = 0; i < n; i++){
    currentVal = arr[i];
    j = i - 1;
    while(j >= 0 && arr[j] < currentVal){
      arr[j+1] = arr[j];
      j = j - 1;
    }
    arr[j+1] = currentVal;
  }
}

void printArray(int arr[], int n){
  printf("[ ");
  for(int i = 0; i < n; i++){
    if(i == n - 1){
      printf("%d ]\n", arr[i]);
    }else{
      printf("%d, ", arr[i]);
    }
  }
  printf("Fin del ordenamiento\n");
}

int main(){
  int arr[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443,-6693,
  9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542,
  -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452,
  -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 
  2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099,6399,
  -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226,
  9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277,
  1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871,
  9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997,
  -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916,
  -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553,
  9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256,
  -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941,
  8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162,
  -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501,
  -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670,
  -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164,
  3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689,
  7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882,
  5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459,5008, 3352, 6586, 537, -7610, 3261,
  8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323,
  -6485, -4828, -5294, -2720, 595};
  int n = sizeof(arr)/sizeof(arr[0]);

  InsertionSort(arr, n);
  printArray(arr, n);

  return 0;
}
![Screenshot 2020-10-24 163903.jpg](https://static.platzi.com/media/user_upload/Screenshot%202020-10-24%20163903-7a335b58-f9de-4bf7-9824-1533880fbcb6.jpg)

Hola Compañer@s

comparto mi codigo

#include<stdio.h>
#include<math.h>

void insertionSort(int vector1[], int n)
{
int i, valorActual, j;
for(i=1; i<n; i++)
{
valorActual = vector1[i];
j=i-1;
while(j>=0&&vector1[j]<valorActual)
{
vector1[j+1]=vector1[j];
j=j-1;
}
vector1[j+1]=valorActual;
}
}

void imprimirVector(int vector1[], int n)
{
int i;
for(i=0; i<n; i++)
{
printf("%d ,", vector1[i]);
}
printf("\n");
}

int main()
{
int vector1[]= {-796,3229,
-5164,
-362,
4408,
8965,
-6068,
9329,
-3034,
-443,
-6693,
9497,
2615,
-5966,
-9065,
-1160,
6148,
5517,
1123,
-8887,
5649,
3302,
-1176,
-8542,
-9166,
8,
-2906,
8987,
-2414,
-7984,
4410,
8872,
5241,
-4556,
59,
-5562,
-3877,
7452,
-4467,
2076,
4076,
4297,
-3847,
-2055,
4483,
-1484,
-2371,
6199,
-7261,
-7032,
6010,
2325,
-6625,
-2601,
3870,
1822,
-5665,
9622,
9883,
-5794,
-5218};
int n = sizeof(vector1)/sizeof(vector1[0]);
insertionSort(vector1, n);
imprimirVector(vector1, n);
}

Lo que hice fue copiar los numeros que dejo el profesor Celis, pegarlos en un string literal en javascript llamado “dataset” y luego hacer

dataset = dataset.split('\n');

Eso me daria un array con todos los numeros, pero en forma de String, asi que parsee todos los valores con

dataset = dataset.map(v => parseInt(v))

Luego de tener mi array con los valores en enteros correctamente, hice mi funcion de ordenamiento, use un snsertion sort, porque el bubble sort ya lo sabia hacer porque lo aprendi en la universidad y nunca habia hecho antes un insertion sort.

let insertionSort = (arr) => {
  for (let i = 1; i < arr.length; i++) {
    let j = i - 1;
    let currentVal = arr[i];
    while(j >= 0 && arr[j] > currentVal) {
      arr[j+1] = arr[j];
      j--;
    }
    arr[j+1] = currentVal;
  }
  return arr;
}

y mi resultafo fue:

[-9999,-9954,-9941,-9846,-9803,-9669,-9226,-9210,-9166,-9136,-9076,-9065,-8887,-8882,-8834,-8744,-8670,-8651,-8614,-8542,-8412,-8358,-8323,-8230,-8054,-8026,-8004,-7984,-7886,-7885,-7875,-7610,-7449,-7442,-7261,-7228,-7060,-7032,-6953,-6939,-6826,-6693,-6688,-6625,-6558,-6485,-6338,-6256,-6234,-6153,-6096,-6068,-5991,-5966,-5794,-5709,-5665,-5562,-5555,-5350,-5294,-5277,-5218,-5164,-5156,-5147,-5065,-5060,-5022,-4828,-4755,-4729,-4727,-4689,-4650,-4556,-4553,-4467,-4420,-4379,-4111,-4098,-4031,-3877,-3847,-3674,-3668,-3576,-3535,-3269,-3261,-3260,-3181,-3099,-3066,-3034,-2980,-2948,-2940,-2925,-2906,-2905,-2871,-2796,-2720,-2691,-2685,-2601,-2570,-2541,-2438,-2414,-2409,-2371,-2204,-2105,-2099,-2089,-2083,-2055,-1997,-1981,-1793,-1766,-1683,-1666,-1634,-1610,-1574,-1484,-1446,-1176,-1160,-1078,-1062,-1062,-1018,-916,-796,-749,-702,-673,-501,-479,-443,-429,-369,-362,-362,-239,-238,8,23,59,200,458,537,595,676,680,766,824,946,1032,1065,1123,1175,1229,1246,1305,1455,1505,1635,1822,1936,2037,2076,2228,2325,2461,2565,2615,2649,2732,2770,2772,2926,3077,3096,3164,3229,3261,3287,3302,3352,3368,3372,3536,3577,3672,3682,3786,3870,3943,4076,4222,4297,4302,4397,4408,4408,4410,4483,4575,4624,4632,4735,4800,4926,4957,5008,5063,5073,5106,5107,5114,5219,5241,5361,5487,5517,5574,5622,5649,5650,5850,5904,6010,6148,6187,6199,6291,6356,6399,6410,6586,6637,6662,6679,6741,6796,6941,7079,7137,7177,7201,7236,7387,7452,7629,7831,7878,7889,7891,7957,7966,8208,8233,8246,8252,8459,8502,8523,8553,8578,8599,8681,8762,8780,8830,8872,8965,8987,9131,9162,9222,9254,9329,9421,9448,9497,9521,9545,9551,9622,9720,9791,9883,9885,9976]

Reto Cumplido utilice Metodo Burbuja de la ultima clase

#include<stdio.h>

void cambiar_pos(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void bubbleSort(int vector_entrada[], int n)
{
    int i;
    int j;
    for(i=0; i < n-1; i++)
    {
        for(j=0; j < n-i-1; j++)
        {
            //[10, 5, 3, 3333]
            if(vector_entrada[j]<vector_entrada[j+1])
            cambiar_pos(&vector_entrada[j],&vector_entrada[j+1]);
        }
    }
}

int print_array(int vector_entrada[], int n)
{
    int i;
    for(i=0; i<n-1; i++)
        printf("%d ,", vector_entrada[i]);
    printf("\n fin del ordenamiento");
}

main(int argc, char const *argv[])
{
    int vector_entrada[]={-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906
				 ,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625
				 ,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222
				 ,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,
				 -2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,
				 -9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673
				 ,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026
				 ,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501
				 ,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662
				 ,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6,410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830
				 ,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957
				 ,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595};
    int n = sizeof(vector_entrada)/sizeof(vector_entrada[0]);
    bubbleSort(vector_entrada, n);
    print_array(vector_entrada, n);
    printf("\n");
    return 0;
}

Resultado

Yo utilice Bubble Sort y Insertion Sort. Adjunto los tiempos de ejecucion para cada uno de los algoritmos.

BUBBLE SORT

INSERTION SORT

#include <iostream>

using namespace std;

void printArr(int data[], int size)
{
  for (int i = 0; i < size; i++)
  {
    std::cout << data[i] << ", ";
  }
}

void bubbleSort(int data[], int size)
{
  for (int i = 0; i <= size; i++)
  {
    for (int j = 0; j <= size; j++)
    {
      if (data[j] > data[j + 1])
      {
        int temp = data[j];
        data[j] = data[j + 1];
        data[j + 1] = temp;
      }
    }
  }
}

void insertionSort(int data[], int size)
{
  for (int i = 0; i <= size - 1; i++)
  {
    int current = i;

    for (int j = i; j >= 0; j--)
    {
      if (data[current] < data[j])
      {
        int temp = data[current];
        data[current] = data[j];
        data[j] = temp;
        current = j;
      }
    }
  }
}

Hice mi propia función bubble sort basándome en lo que aprendí aquí

void bubbleSort(int iarray[], int isizeArray)
{
    for(int y = 0; y < isizeArray; y++)            // 5)
    {

        for(int i = 1; i < isizeArray - y; i++)   // 1)
        {
            int currentVal = 0;                   // 3)
            int j;                                // 2)
            j = i - 1;

            if( iarray[j] > iarray[i] )           //4)
            {
                currentVal = iarray[i];
                iarray[i] = iarray[j];
                iarray[j] = currentVal;
            }```

Hola, les comparto mi solución utilizando Insertion Sort en C#:

Código Fuente

using System;

namespace insertion_sort
{
  public class InsertionSort
  {
    public void Sort(ref int[] target, short order = 1)
    {
      int first, second, currentIndex;

      for (int index = 1; index < target.Length; index++)
      {
        currentIndex = index;
        while (currentIndex > 0)
        {
          first = target[currentIndex];
          second = target[currentIndex - 1];

          if ((order == 1 && first < second) || (order == -1 && first > second))
          {
            target[currentIndex - 1] = first;
            target[currentIndex] = second;
          }

          currentIndex--;
        }
      }
    }
  }
}

Solución del desafío

using System;

public class Program
{
	public class InsertionSort
	{
		public void Sort(ref int[] target, short order = 1)
		{
			int first, second, currentIndex;
			for (int index = 1; index < target.Length; index++)
			{
				currentIndex = index;
				while (currentIndex > 0)
				{
					first = target[currentIndex];
					second = target[currentIndex - 1];
					if ((order == 1 && first < second) || (order == -1 && first > second))
					{
						target[currentIndex - 1] = first;
						target[currentIndex] = second;
					}

					currentIndex--;
				}
			}
		}
	}

	public static void Main()
	{
		InsertionSort insertionSort = new InsertionSort();
		int[] target = new int[]{-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};
		
		printf("Original set: 		{0}", target);
		
		insertionSort.Sort(ref target);
		printf("Ordered set asc: 	{0}", target);
		
		insertionSort.Sort(ref target, -1);
		printf("Ordered set desc: 	{0}", target);
	}
	
	private static void printf(string prefix, int[] array) {
		string text = "";
		foreach(int item in array) {
			text = text + item + ", ";
		}
		text = text.Substring(0, text.Length - 2);
		Console.WriteLine(prefix, text);
	}
}

Hice una implementación del SelectionSort. Esta medio ineficiente por el uso de variables pero así fue que lo entendí. Saque la info de aquí.

//Desafío uno

#include <stdio.h>

int main(int argc, char const *argv[]){
    int i,j,last, enter;
    int v[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497, 2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414, -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371, 6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943, -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098, 946, -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177, -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502, 3536, -2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624, -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850, 7387, -3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066, -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966, -2905, 7629, 7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875, -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181, -8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925, -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};
    int n = sizeof(v)/sizeof(int);
    for(i = 0; i < n; i++){
        int min = v[i];
        enter = 0;
        for(j = i;j<n;j++){
            if(v[j]<min){
                min = v[j];
                last = j;
                enter = 1;
            }
        }
        if(enter == 1){    
            v[last] = v[i];
            v[i] = min;
        }
    }
    
    for(i = 0; i < n; i++){
        printf("%i ",v[i]);
    }
    
    return 0;
}

Cuando tenemos gran cantidad de datos como en este desafío resulta útil tener una función que nos permite chequear rápidamente si los datos fueron ordenados correctamente y pensando en eso hice está a continuación:

bool check (int iarray[], int isize, bool iflag)
{
    for(int i = 1; i<isize; i++)
    {
        iflag = true;
        int j = i - 1;

        if(iarray[i] < iarray[j])
        {
            return iflag = false;
        }
    }
return iflag = true;
}   // piece of code to check if the sorting is OK or not```

subo mi solucion usando insertionSort

#include <stdio.h>
#include <math.h>

void insertionSort(int arr[], int n) {
    int i, currentVal, j;
    for (i = 1; i < n; i ++) {
        currentVal = arr[i];
        j = i - 1;
        while (j >= 0 &&  arr[j] > currentVal) {
            arr[j + 1] = arr[j];
            j = j - 1;
        }
        arr[j +1] = currentVal;
    }
}

void printArray(int arr[], int n) {
    int  i;
    for (i=0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
}

int main(int argc, char const *argv[])
{
    int arr[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6,410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595}; 
    int n = sizeof(arr)/sizeof(arr[0]);

    insertionSort(arr, n);
    printArray(arr, n);
    return 0;
}

#include<stdio.h>

void  cambiar_pos(int *n1, int *n2)
{
    int temp = *n1;
    *n1 = *n2;
    *n2 = temp;
}

void bubbleSort(int arrayInput[], int n)
{
    int i, j;
    for (i = 0; i < n-1; i++)
    {
        for (j = 0; j < n-i-1; j++)
        {
            if (arrayInput[j] > arrayInput[j+1])
            {
                cambiar_pos(&arrayInput[j], &arrayInput[j+1]);
            }
        }
    }
}

int printArray(int arrayInput[], int n)
{
    int i;
    for (i = 0; i < n; i++)
    {
        printf("%d, ", arrayInput[i]);

    }
    printf("\n Fin del ordenamiento");
}

main(int argc, char const *argv[])
{
    int arrayInput[]={796,	3229,	-5164,	-362,	4408,	8965,	-6068,	9329,	-3034,	-443,	-6693,
    9497,	2615,	-5966,	-9065,	-1160,	6148,	5517,	1123,	-8887,	5649,	3302,	-1176,	-8542,
    -9166,	8,	-2906,	8987,	-2414,	-7984,	4410,	8872,	5241,	-4556,	59,	-5562,	-3877,	7452,
    -4467,	2076,	4076,	4297,	-3847,	-2055,	4483,	-1484,	-2371,	6199,	-7261,	-7032,	6010,
    2325,	-6625,	-2601,	3870,	1822,	-5665,	9622,	9883,	-5794,	-5218,	2926,	8599,	-3099,
    6399,	-2570,	3943,	-2409,	5114,	9791,	-4420,	1065,	3077,	-1062,	-8004,	4397,	1635,
    8578,	-9226,	9222,	-1793,	-2691,	-5060,	-4727,	-4098,	946,	-6558,	-4111,	4575,	-2685,
    -4729,	-5277,	1936,	5106,	-2089,	824,	9421,	-1683,	-2083,	7891,	-2099,	1305,	-9076,
    -3535,	2565,	-2871,	9448,	7177,	-8614,	-9954,	-362,	1455,	-8834,	-9846,	-8412,	1175,
    -1981,	-5991,	7201,	-1997,	-5156,	-1634,	-9803,	1032,	9551,	-6153,	8502,	3536,	-2980,
    8681,	-9210,	4408,	8780,	-916,	-369,	-8651,	1246,	-702,	-5555,	23,	8208,	2037,	6941,
    9545,	-5147,	5063,	-8358,	2772,	8553,	9885,	4624,	-3576,	9131,	1229,	-429,	-479,
    -673,	-7060,	-4031,	5650,	6679,	6796,	5622,	-6256,	-238,	-6096,	3096,	-1610,	-2948,
    6291,	-1666,	5219,	5850,	7387,	-3260,	3672,	-1766,	-9941,	8252,	2649,	7079,	-8026,
    6356,	676,	-5065,	-6338,	3287,	680,	-3269,	2770,	6637,	-8744,	9162,	-2204,	-3066,
    -7228,	8762,	1505,	4957,	766,	-9136,	4632,	-5022,	-9999,	5361,	2732,	7831,	-501,
    -4650,	7236,	3682,	-2438,	5574,	-8230,	-9669,	-7442,	7966,	-2905,	7629,	7137,	200,
    -8670,	-749,	2228,	458,	7889,	-3668,	-5350,	-3261,	6741,	-6953,	4800,	3372,	6662,
    -1018,	8523,	3164,	3577,	9720,	-6826,	-1574,	-7875,	-2796,	-1078,	-4755,	4926,	3368,
    4302,	9254,	6410,	-4689,	7878,	2461,	8233,	-6688,	5904,	4735,	-2940,	8830,	9976,
    -3674,	4222,	-1446,	6187,	-3181,	-8882,	5487,	-6939,	-7885,	3786,	-6234,	-1062,	-4553,
    -5709,	8459,	5008,	3352,	6586,	537,	-7610,	3261,	8246,	-2105,	5107,	7957,	-7886,
    -2925,	-2541,	-7449,	9521,	5073,	-239,	-8054,	-4379,	-8323,	-6485,	-4828,	-5294,	-2720,	595};
    int n = sizeof(arrayInput)/sizeof(arrayInput[0]);



    bubbleSort(arrayInput,n);

    printf("\n\tArray de %d elementos ordenado\n\n ", n);
    printArray(arrayInput,n);
    printf("\n\n\n\t");

    return 0;
}

Código hecho en java

public class ordBurbuja{

public static void main(String[] args) {

    int array1[] = {-796, 3229, -5164, -362, 4408, 8965, -6068, 9329, -3034, -443, -6693, 9497,
        2615, -5966, -9065, -1160, 6148, 5517, 1123, -8887, 5649, 3302, -1176, -8542, -9166, 8, -2906, 8987, -2414,
        -7984, 4410, 8872, 5241, -4556, 59, -5562, -3877, 7452, -4467, 2076, 4076, 4297, -3847, -2055, 4483, -1484, -2371,
        6199, -7261, -7032, 6010, 2325, -6625, -2601, 3870, 1822, -5665, 9622, 9883, -5794, -5218, 2926, 8599, -3099, 6399, -2570, 3943,
        -2409, 5114, 9791, -4420, 1065, 3077, -1062, -8004, 4397, 1635, 8578, -9226, 9222, -1793, -2691, -5060, -4727, -4098, 946,
        -6558, -4111, 4575, -2685, -4729, -5277, 1936, 5106, -2089, 824, 9421, -1683, -2083, 7891, -2099, 1305, -9076, -3535, 2565, -2871, 9448, 7177,
        -8614, -9954, -362, 1455, -8834, -9846, -8412, 1175, -1981, -5991, 7201, -1997, -5156, -1634, -9803, 1032, 9551, -6153, 8502,
        3536, -2980, 8681, -9210, 4408, 8780, -916, -369, -8651, 1246, -702, -5555, 23, 8208, 2037, 6941, 9545, -5147, 5063, -8358, 2772, 8553, 9885, 4624,
        -3576, 9131, 1229, -429, -479, -673, -7060, -4031, 5650, 6679, 6796, 5622, -6256, -238, -6096, 3096, -1610, -2948, 6291, -1666, 5219, 5850,
        7387, -3260, 3672, -1766, -9941, 8252, 2649, 7079, -8026, 6356, 676, -5065, -6338, 3287, 680, -3269, 2770, 6637, -8744, 9162, -2204, -3066,
        -7228, 8762, 1505, 4957, 766, -9136, 4632, -5022, -9999, 5361, 2732, 7831, -501, -4650, 7236, 3682, -2438, 5574, -8230, -9669, -7442, 7966,
        -2905, 7629, 7137, 200, -8670, -749, 2228, 458, 7889, -3668, -5350, -3261, 6741, -6953, 4800, 3372, 6662, -1018, 8523, 3164, 3577, 9720, -6826, -1574, -7875,
        -2796, -1078, -4755, 4926, 3368, 4302, 9254, 6410, -4689, 7878, 2461, 8233, -6688, 5904, 4735, -2940, 8830, 9976, -3674, 4222, -1446, 6187, -3181,
        -8882, 5487, -6939, -7885, 3786, -6234, -1062, -4553, -5709, 8459, 5008, 3352, 6586, 537, -7610, 3261, 8246, -2105, 5107, 7957, -7886, -2925,
        -2541, -7449, 9521, 5073, -239, -8054, -4379, -8323, -6485, -4828, -5294, -2720, 595};

    OrdBurbuja obj1 = new OrdBurbuja();
    System.out.println("El arreglo ordenado es: " + obj1.imprimir(array1));
}

public void orBurbuja(int array[]) {

    int aux;
    for (int i = 0; i < array.length - 1; i++) {
        for (int j = 0; j < array.length - 1; j++) {
            if (array[j] > array[j + 1]) {
                aux = array[j + 1];
                array[j + 1] = array[j];
                array[j] = aux;
            }
        }
    }
}

public String imprimir(int array[]) {
    orBurbuja(array);
    int k=0;
    String dato = " ";
   
    for (int i = 0; i <= array.length - 1; i++) {
        dato = dato + array[i] + ",\n ";
    }
    return dato;
}

}

SALIDA
run:
El arreglo ordenado es:
-9999,
-9954,
-9941,
-9846,
-9803,
-9669,
-9226,
-9210,
-9166,
-9136,
-9076,
-9065,
-8887,
-8882,
-8834,
-8744,
-8670,
-8651,
-8614,
-8542,
-8412,
-8358,
-8323,
-8230,
-8054,
-8026,
-8004,
-7984,
-7886,
-7885,
-7875,
-7610,
-7449,
-7442,
-7261,
-7228,
-7060,
-7032,
-6953,
-6939,
-6826,
-6693,
-6688,
-6625,
-6558,
-6485,
-6338,
-6256,
-6234,
-6153,
-6096,
-6068,
-5991,
-5966,
-5794,
-5709,
-5665,
-5562,
-5555,
-5350,
-5294,
-5277,
-5218,
-5164,
-5156,
-5147,
-5065,
-5060,
-5022,
-4828,
-4755,
-4729,
-4727,
-4689,
-4650,
-4556,
-4553,
-4467,
-4420,
-4379,
-4111,
-4098,
-4031,
-3877,
-3847,
-3674,
-3668,
-3576,
-3535,
-3269,
-3261,
-3260,
-3181,
-3099,
-3066,
-3034,
-2980,
-2948,
-2940,
-2925,
-2906,
-2905,
-2871,
-2796,
-2720,
-2691,
-2685,
-2601,
-2570,
-2541,
-2438,
-2414,
-2409,
-2371,
-2204,
-2105,
-2099,
-2089,
-2083,
-2055,
-1997,
-1981,
-1793,
-1766,
-1683,
-1666,
-1634,
-1610,
-1574,
-1484,
-1446,
-1176,
-1160,
-1078,
-1062,
-1062,
-1018,
-916,
-796,
-749,
-702,
-673,
-501,
-479,
-443,
-429,
-369,
-362,
-362,
-239,
-238,
8,
23,
59,
200,
458,
537,
595,
676,
680,
766,
824,
946,
1032,
1065,
1123,
1175,
1229,
1246,
1305,
1455,
1505,
1635,
1822,
1936,
2037,
2076,
2228,
2325,
2461,
2565,
2615,
2649,
2732,
2770,
2772,
2926,
3077,
3096,
3164,
3229,
3261,
3287,
3302,
3352,
3368,
3372,
3536,
3577,
3672,
3682,
3786,
3870,
3943,
4076,
4222,
4297,
4302,
4397,
4408,
4408,
4410,
4483,
4575,
4624,
4632,
4735,
4800,
4926,
4957,
5008,
5063,
5073,
5106,
5107,
5114,
5219,
5241,
5361,
5487,
5517,
5574,
5622,
5649,
5650,
5850,
5904,
6010,
6148,
6187,
6199,
6291,
6356,
6399,
6410,
6586,
6637,
6662,
6679,
6741,
6796,
6941,
7079,
7137,
7177,
7201,
7236,
7387,
7452,
7629,
7831,
7878,
7889,
7891,
7957,
7966,
8208,
8233,
8246,
8252,
8459,
8502,
8523,
8553,
8578,
8599,
8681,
8762,
8780,
8830,
8872,
8965,
8987,
9131,
9162,
9222,
9254,
9329,
9421,
9448,
9497,
9521,
9545,
9551,
9622,
9720,
9791,
9883,
9885,
9976,
BUILD SUCCESSFUL (total time: 0 seconds)

Aquí esta en JS Bubble Sort:

Yo lo hice implementando el algoritmo QuickSort.
Lo busque en google y luego lo descompuse para ver como funciona.

#include<stdio.h>
#include<stdbool.h>
#define SIZE 300



void qs(int list[], int limit_left, int limit_right)
{
    int n, right, left, pivot;

    left = limit_left;
    right = limit_right;

    pivot = list[(left+right)/2];


    do{
        while(list[left] < pivot && left < limit_right) left++;
        while(pivot < list[right] && right > limit_left)right--;

        if(left <= right)
        {
            int temporal = list[left];

            list[left] = list[right];
            list[right] = temporal;

            left++;
            right--;
        }
    }while(left <= right);
    if(limit_left < right){qs(list, limit_left, right);}
    if(limit_right > left){qs(list, left, limit_right);}

}


void quicksort(int list[], int n)
{
    qs(list, 0, n-1);
}


void print_array(int list[], int n,bool sorted)
{   
    int i;
    if(sorted == 0)
    {
        printf("El array, desordenado  \n");
        for(i = 0; i < n; i++)
        {
            printf("%d,",list[i]);
        }
        printf("\n \n");
    }else
        {
            printf("El array, ordenado \n");
            for(i = 0; i < n; i++)
            {
                printf("%d,", list[i]);
            }
            printf("\n \n");
        }
}




int main(int argc, char const *argv[])
{
    int i;
    int list[SIZE];
    int size = sizeof(list)/sizeof(list[0]);


    FILE *myFile;

    myFile = fopen("numeros_array.dat", "rb");


    for(i = 0; i < SIZE; i++)
    {
        fscanf(myFile, "%d", &list[i]);
    }


    print_array(list, size, 0);

    quicksort(list, size);

    print_array(list, size, 1);

    fclose(myFile);

    return 0;
}

Reto Cumplido!, la parte de FILE la saque del código de DaneSanchz https://platzi.com/@DaneSanchz!

#include "stdio.h"
#define n 300

int array[n];

void nOrden(int i, int j)
{
	int bubble=0;
	if(array[i] > array[j])
	{
		bubble = array[i];
		array[i] = array[j];
		array[j] = bubble;
	}
}

int main(int argc, char const *argv[])
{
    FILE *archivo;
    int arr[n];
    archivo = fopen("numbers.dat", "rb"); // abrir archivo en modo lectura

    if(archivo != NULL) // si se abrió el archivo
    {
    	for (int i = 0; i < n; ++i)
        {
        	fscanf(archivo, "%d", &array[i]); // leer datos del archivo
        	for (int j = 0; j < n; ++j)
        	{
        		nOrden(i,j);
        	}
        }

        fclose(archivo); // cerrar el archivo

        for (int i = 0; i < n; ++i)
        {
        	printf("%d ,", array[i]);
        }
    } 
    else
    {
        printf("No se leyo el archivo");
    }

	return 0;
}

Utilize el bubbleSort y adicione las siguientes funciones:

scanf ("%d", &Opcion); //Para que el usuario decida si quiere organizar de manera Descendente o Ascendente
fopen("array.txt", "rb"); //Abre un archivo en modo binario para lectura
fscanf(archivo, "%d", &array[i]); //Funciona igual que scanf en cuanto a parámetros, pero la entrada se toma de un fichero en lugar del teclado
fclose(archivo); //Esta función sirve para poder cerrar un fichero que se ha abierto

Aqui les dejo el codigo completo

#include <stdio.h> 
#define SIZE 300

int array[SIZE];

void cambiar_pos(int *n1, int *n2) 
{
	int temp =*n1;
	*n1 = *n2;
	*n2 = temp;
}

void bubbleSort(int vector_entrada[], int n)
{
	int i, j, Opcion; 
	printf("Digite la opcion que desea ejecutar: \n 1.Descendente \n 2.Ascendente \n");
	scanf ("%d", &Opcion); 
	if(Opcion==1) 
	{	
		for (i=0; i < n-1; i++)
		{
			for(j=0; j < n-i-1; j++)
			{
				if(vector_entrada[j] < vector_entrada[j+1])
				cambiar_pos(&vector_entrada[j],&vector_entrada[j+1]);
			}
		}
	}
	if(Opcion==2) 
	{
		for (i=0; i < n-1; i++)
		{
			for(j=0; j < n-i-1; j++)
			{
				if(vector_entrada[j] > vector_entrada[j+1])
				cambiar_pos(&vector_entrada[j],&vector_entrada[j+1]);
			}
		}
	}
	if(Opcion != 1 && Opcion != 2)
	{
		printf("No es un opcion valida, el array no ha cambiado \n");
	}

}

void leerArchivo()
{
  FILE *archivo;
  archivo = fopen("array.txt", "rb"); 

  if(archivo != NULL) 
  {
    for(int i = 0; i < SIZE; i++)
    	fscanf(archivo, "%d", &array[i]); 
    	fclose(archivo); 
  }
  else
    printf("File error");
}

int print_array(int vector_entrada[], int n)
{
	int i;
	for(i=0; i < n; i++)
		printf("%d  ,", vector_entrada[i]);
	printf("\n Fin del ordenamiento");
}

int main(int argc, char const *argv[])
{
	leerArchivo();
	bubbleSort(array, SIZE);
	print_array(array, SIZE);
	printf("\n");
	return 0;
}

Reto con insertionSort:

Reto con bubbleSort:

Reto completado, gracias a DaneSanchz https://platzi.com/@DaneSanchz por el manejo de archivos .txt para la implementación

#include <stdio.h>
#define SIZE 300

void cambiar_pos(int *n1, int *n2)
{
	int temp = *n1;		
	*n1 = *n2;
	*n2 = temp;
}

void bubbleSort(int vector_entrada[], int n)
{
	int i, j;
	for(i=0; i< n-1; i++)
	{
		for(j=0; j < n-i-1; j++)
		{
			if(vector_entrada[j]<vector_entrada[j+1])
			cambiar_pos(&vector_entrada[j],&vector_entrada[j+1]);
			
		}
	}
}

int print_array(int vector_entrada[], int n)
{
	int i;
	for(i=0; i<n+1; i++)
		printf("%d  ,", vector_entrada[i]);
	printf("\n fin del ordenamiento");
}

main(int argc, char const *argv[])
{

	FILE *array;	
	int arr[SIZE];
	array = fopen("array.txt", "r");
	
	if(array != NULL)
	{
		int i;
		for(i = 0; i < SIZE; i++)
			fscanf(array, "%d", &arr[i]);		
	 
		fclose(array);	
	
		bubbleSort(arr,SIZE);
		print_array(arr,SIZE);
		printf("\n");
	}
	else
		printf("No se leyó el array de datos");
	return 0;
}```

Saludos a todos.
Decanté por usar el ordenamiento Shell.
Pasé varios días pensando, escribiendo y borrando pseudocódigo, prueba y error, hasta lograr un resultado satisfactorio.
El método de ordenamiento Shell es similar al ordenamiento de Inserción, solo que en Shell se usan saltos decrecientes para comparación de las celdas, en lugar de usar comparaciones con las celdas adyacentes como en Inserción normal. En el último paso de Shell, el ordenamiento se hace tal cual una Inserción normal.
Código es:

#include <stdio.h>

void shellSort(int arr[], int cant)
{
   int i, j, k, temp;
   int inc = cant; //asignar a incremento la longitud del arreglo por primera vez
   do
   {
       inc = inc/2; //dividir longitud del arreglo entre 2 cada pasada
       for(k=0; k<inc; k++) //recorrer el subarreglo de longitud "inc"
       {
           for(i=inc+k; i<cant; i=i+inc) //aplicar el método Shell a todos los elementos del arreglo original
           {
              j=i-inc;
              while(j>=0 && arr[j+inc] > arr[j]) //recorrer y comparar subarreglo estilo Insertion Sort
              {
                  //intercambio(arr[j], arr[j-inc]);
                  temp = arr[j+inc];
                  arr[j+inc] = arr[j];
                  arr[j] = temp;
                  j=j-inc;
              }
           }
              
       }
   }while (inc>1); //terminar ordenamiento una vez los incrementos sean menores a 1
   printf("\nArreglo ordenado: \n");
}

void imprimirArreglo(int arreglo[], int e)
{
   int i;
   for(i=0; i<e; i++)
      printf("%d  ,", arreglo[i]);
}

void main()
{
    int arreglo[] = {-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595};
    int elementos = sizeof(arreglo)/sizeof(arreglo[0]); //obtener longitud del arreglo
    imprimirArreglo(arreglo, elementos);
    shellSort(arreglo, elementos);
    imprimirArreglo(arreglo, elementos);
    printf("\nFin del ordenamiento");
}

Pueden ver su ejecución aquí

Reto cumplido siguiendo la lógica del insertion Sort

void metodoDeInsercion(p vector, int n){
		
	for(int i = 0; i < n; i++){
		
		int pos = i;
		
		while(pos > 0){
			
			if(vector[pos]>vector[pos-1]){
				int aux = vector[pos];
				vector[pos] = vector[pos-1];
				vector[pos - 1] = aux;
			}
			pos--;
		}	
	}	
}

Hola, realice el desafió aplicando el método de insertion sort.

#include "stdio.h"

void insertion_sort(int vector_entrada[],int n){
int temporal;
int indice;

for(int i=0;i<n;i++){

indice=i;
for(int j=indice-1;j>-1;j--){
if(indice>-1){
if(vector_entrada[indice]>vector_entrada[j]){
temporal=vector_entrada[j];
vector_entrada[j]=vector_entrada[indice];
vector_entrada[indice]=temporal;
indice--;
}
}    
}
}

for(int t=0;t<n;t++){
printf("\n index: %d | value: %d \n",t,vector_entrada[t]);
}

}


int main(int argc, char const *argv[])
{   
int vector_entrada[]={-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,
-8887,5649,3302,-1176,-8542,-9166,8,-2906,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,
-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,8599,-3099,6399,-2570,
3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,
-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,-2871,9448,7177,-8614,-9954,-362,1455,
-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,-9210,4408,8780,-916,-369,
-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673,-7060,-4031,
5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026,6356,
676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501,
-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,
6662,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6410,-4689,7878,2461,8233,-6688,5904,4735,-2940,
8830,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,
5107,7957,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595};

int n=sizeof(vector_entrada)/sizeof(vector_entrada[0]);

insertion_sort(vector_entrada,n);

    return 0;
}

Con Insertion sort y python:

#! /usr/bin/python


if __name__ == '__main__':
    lista = [-796,3229,-5164,-362,4408,8965,-6068,9329,-3034,-443,-6693,9497,2615,-5966,-9065,-1160,6148,5517,1123,-8887,5649,3302,-1176,-8542,-9166,8,-2906
				 ,8987,-2414,-7984,4410,8872,5241,-4556,59,-5562,-3877,7452,-4467,2076,4076,4297,-3847,-2055,4483,-1484,-2371,6199,-7261,-7032,6010,2325,-6625
				 ,-2601,3870,1822,-5665,9622,9883,-5794,-5218,2926,-3099,6399,-2570,3943,-2409,5114,9791,-4420,1065,3077,-1062,-8004,4397,1635,8578,-9226,9222
				 ,-1793,-2691,-5060,-4727,-4098,946,-6558,-4111,4575,-2685,-4729,-5277,1936,5106,-2089,824,9421,-1683,-2083,7891,-2099,1305,-9076,-3535,2565,
				 -2871,9448,7177,-8614,-9954,-362,1455,-8834,-9846,-8412,1175,-1981,-5991,7201,-1997,-5156,-1634,-9803,1032,9551,-6153,8502,3536,-2980,8681,
				 -9210,4408,8780,-916,-369,-8651,1246,-702,-5555,23,8208,2037,6941,9545,-5147,5063,-8358,2772,8553,9885,4624,-3576,9131,1229,-429,-479,-673
				 ,-7060,-4031,5650,6679,6796,5622,-6256,-238,-6096,3096,-1610,-2948,6291,-1666,5219,5850,7387,-3260,3672,-1766,-9941,8252,2649,7079,-8026
				 ,6356,676,-5065,-6338,3287,680,-3269,2770,6637,-8744,9162,-2204,-3066,-7228,8762,1505,4957,766,-9136,4632,-5022,-9999,5361,2732,7831,-501
				 ,-4650,7236,3682,-2438,5574,-8230,-9669,-7442,7966,-2905,7629,7137,200,-8670,-749,2228,458,7889,-3668,-5350,-3261,6741,-6953,4800,3372,6662
				 ,-1018,8523,3164,3577,9720,-6826,-1574,-7875,-2796,-1078,-4755,4926,3368,4302,9254,6,410,-4689,7878,2461,8233,-6688,5904,4735,-2940,8830
				 ,9976,-3674,4222,-1446,6187,-3181,-8882,5487,-6939,-7885,3786,-6234,-1062,-4553,-5709,8459,5008,3352,6586,537,-7610,3261,8246,-2105,5107,7957
				 ,-7886,-2925,-2541,-7449,9521,5073,-239,-8054,-4379,-8323,-6485,-4828,-5294,-2720,595]
    print('initial', lista)
    for k in lista:
        for i, value in enumerate(lista):
            # print(lista)
            if i == 0:
                continue
            else:
                for j in range(i):
                    if lista[i] > lista[i-1]:
                        lista[i], lista[i-1] = lista[i-1], lista[i]
    print(lista)

#include <stdio.h>
#include <math.h>

/* Función de insertion Sort*/
void insertionSort(int arr[], int n)
{
int i, currentVal;
for (i = 0; i < n-1; i++)
{
if(arr[i] < arr[i+1]){
currentVal = arr[i];
arr[i] = arr[i+1];
arr[i+1] = currentVal;
i = -1;
}
}
}

// función auxiliar para imprimir un arrary de tamaño n
void printArray(int arr[], int n)
{
int i;
for (i=0; i < n; i++)
printf("%d “, arr[i]);
printf(”\n");
}

/* Driver program to test insertion sort */
int main()
{
int arr[] = {-796, 3229, -5164, -362, 4408, 5517, 1123,
3877, 7452, 59, -3877, 9622, 4397, -8004, 9791, 1635 };
int n = sizeof(arr)/sizeof(arr[0]);

insertionSort(arr, n); 
printArray(arr, n); 

return 0; 

}

Sólo es cambiar el signo menor que por mayor que.

#include <stdio.h>
#include <math.h>

/* Función de insertion Sort*/
void insertionSort(int arr[], int n)
{
    int i, currentVal, j;
    for (i = 1; i < n; i++)
    {
        currentVal = arr[i]; //obtenemos el valor actual a comparar
        j = i - 1;

        /* mueve los elementos del arreglo arr[0..i-1],que son mayores que el valor de la posición actual del recorrido, a una posición adelante de su posición actual */
        while (j >= 0 && arr[j] < currentVal)
        {
            arr[j + 1] = arr[j];
            j = j - 1;
        }
        arr[j + 1] = currentVal;
    }
}

// función auxiliar para imprimir un arrary de tamaño n
void printArray(int arr[], int n)
{
    int i;
    for (i = 0; i < n; i++)
        printf("%d ", arr[i]);
    printf("\n");
}

/* Driver program to test insertion sort */
int main()
{
    int arr[] = {-796
,3229
,-5164
,-362
,4408
,8965
,-6068
,9329
,-3034
,-443
,-6693
,9497
,2615
,-5966
,-9065
,-1160
,6148
,5517
,1123
,-8887
,5649
,3302
,-1176
,-8542
,-9166
,8
,-2906
,8987
,-2414
,-7984
,4410
,8872
,5241
,-4556
,59
,-5562
,-3877
,7452
,-4467
,2076
,4076
,4297
,-3847
,-2055
,4483
,-1484
,-2371
,6199
,-7261
,-7032
,6010
,2325
,-6625
,-2601
,3870
,1822
,-5665
,9622
,9883
,-5794
,-5218
,2926
,8599
,-3099
,6399
,-2570
,3943
,-2409
,5114
,9791
,-4420
,1065
,3077
,-1062
,-8004
,4397
,1635
,8578
,-9226
,9222
,-1793
,-2691
,-5060
,-4727
,-4098
,946
,-6558
,-4111
,4575
,-2685
,-4729
,-5277
,1936
,5106
,-2089
,824
,9421
,-1683
,-2083
,7891
,-2099
,1305
,-9076
,-3535
,2565
,-2871
,9448
,7177
,-8614
,-9954
,-362
,1455
,-8834
,-9846
,-8412
,1175
,-1981
,-5991
,7201
,-1997
,-5156
,-1634
,-9803
,1032
,9551
,-6153
,8502
,3536
,-2980
,8681
,-9210
,4408
,8780
,-916
,-369
,-8651
,1246
,-702
,-5555
,23
,8208
,2037
,6941
,9545
,-5147
,5063
,-8358
,2772
,8553
,9885
,4624
,-3576
,9131
,1229
,-429
,-479
,-673
,-7060
,-4031
,5650
,6679
,6796
,5622
,-6256
,-238
,-6096
,3096
,-1610
,-2948
,6291
,-1666
,5219
,5850
,7387
,-3260
,3672
,-1766
,-9941
,8252
,2649
,7079
,-8026
,6356
,676
,-5065
,-6338
,3287
,680
,-3269
,2770
,6637
,-8744
,9162
,-2204
,-3066
,-7228
,8762
,1505
,4957
,766
,-9136
,4632
,-5022
,-9999
,5361
,2732
,7831
,-501
,-4650
,7236
,3682
,-2438
,5574
,-8230
,-9669
,-7442
,7966
,-2905
,7629
,7137
,200
,-8670
,-749
,2228
,458
,7889
,-3668
,-5350
,-3261
,6741
,-6953
,4800
,3372
,6662
,-1018
,8523
,3164
,3577
,9720
,-6826
,-1574
,-7875
,-2796
,-1078
,-4755
,4926
,3368
,4302
,9254
,6410
,-4689
,7878
,2461
,8233
,-6688
,5904
,4735
,-2940
,8830
,9976
,-3674
,4222
,-1446
,6187
,-3181
,-8882
,5487
,-6939
,-7885
,3786
,-6234
,-1062
,-4553
,-5709
,8459
,5008
,3352
,6586
,537
,-7610
,3261
,8246
,-2105
,5107
,7957
,-7886
,-2925
,-2541
,-7449
,9521
,5073
,-239
,-8054
,-4379
,-8323
,-6485
,-4828
,-5294
,-2720
,595};
    int n = sizeof(arr) / sizeof(arr[0]);

    insertionSort(arr, n);
    printArray(arr, n);

    return 0;
}```

Utilice los dos algoritmos (BubbleSort y InsertSort) para comparar y me di cuenta que Bubble hace el proceso ligeramente mas lento ( 0.1231 seconds) que Insert (.0811 seconds)

arr.sort((a, b)=> {return a - b})