QuickSort

Run Settings
LanguageJavaScript
Language Version
Run Command
const quickSort = (arr)=>{ if(arr.length <= 1) return arr; let pivot = arr[0]; let left = []; let right = []; for(let i=1;i<arr.length;i++) { if(arr[i]<pivot) left.push(arr[i]) else right.push(arr[i]) } return [...quickSort(left),pivot,...quickSort(right)]; } const array = Array.from({length:100000},(x,i)=>{return Math.floor(Math.random()*i)}) let time = Date.now(); console.log(quickSort(array)); console.log(`Time taken = ${(Date.now()-time)/1000} seconds`);
Editor Settings
Theme
Key bindings
Full width
Lines