This is a sample blog post!
function quicksort(arr) {
if (arr.length <= 1) {
return arr;
}
const pivot = arr[arr.length - 1];
const left = arr.filter((el) => el < pivot);
const right = arr.filter((el) => el > pivot);
return [...quicksort(left), pivot, ...quicksort(right)];
}
// Example usage:
const array = [3, 6, 8, 10, 1, 2, 1];
console.log(quicksort(array)); // Output: [1, 1, 2, 3, 6, 8, 10]