A few easy sorting algorithms implemented in swift and used in swiftUI
The bubbleSort function iterates over the array, comparing adjacent elements and swapping them if they are out of order.
This process is repeated until the array is fully sorted.
A key is compared with a element before the current one (previousIndex) and the function shift them one position to the right if they are greater than the key. The process is continued until the function finds the correct position for the key or reach the beginning of the array.