const sort =(arr)=>{
if(arr.length<=1){
return arr;
}
let pivot = arr[0];
let min = [];
let max=[];
for (let i =1;i<arr.length;i++){
if(arr[i]<pivot){
min.push(arr[i]);
}
else{
max.push(arr[i])
}
}
return [...sort(min),pivot,...sort(max)];
}
sort([1,10000,21,30,4]);
//[1,4,21,30,10000]
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)