JSFiddle - React, Tailwind, and code Playground

JavaScript

const arr = [3, 0, 2, 9, 5, 7, 3, 4, 2, 6, 7, 8];

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

console.log(arr);