const numArray = [20, 30, 34, 12, 3, 12, 2, 4, 5, 9, 4, 34, 1]; const numberSort = (array) => { let temp; for (let i = 0; i < array.length; i++) { for (let j = 0; j < array.length; j++) { if (array[i] > array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } } return array; }; const result = numberSort(numArray); console.log(result);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter