Bubble Sort is a simple comparison-based sorting algorithm that repeatedly steps
through the list, compares adjacent elements, and swaps them if they are in the
wrong order. This process is repeated until the list is sorted.
Time complexity is Quadratic, i.e. O(n²)
Space complexity is Constant, i.e. O(1)
/*!
* @file Bubblesort
* @author Dustin Boston
* @see Cormen, T, Leiserson, C, Rivest, R, and Stein, C. (2001).
* Introduction to Algorithms. (2nd ed). The MIT Press.
*//**
* Sorts an array using the bubble sort algorithm.
*
* @param array The array to be sorted.
*/exportfunctionbubbleSort(array: number[]):void{for(letsortedIndex=0;sortedIndex<array.length;sortedIndex++){for(letcurrentIndex=array.length-1;currentIndex>sortedIndex;currentIndex--){if(array[currentIndex]<array[currentIndex-1]){constswap=array[currentIndex];array[currentIndex]=array[currentIndex-1];array[currentIndex-1]=swap;}}}}