Created
September 27, 2022 12:57
-
-
Save yuriy-o/39b60c25cf5a114ea36c4ba0a017127c to your computer and use it in GitHub Desktop.
QuickSort сортування
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- quicksort ---- | |
// function quicksort(numbers) { | |
// if (numbers.length < 2) return numbers; | |
// const pivot = numbers[0]; | |
// const left = []; | |
// const right = []; | |
// for (let i = 1; i < numbers.length; i++) { | |
// numbers[i] < pivot ? left.push(numbers[i]) : right.push(numbers[i]); | |
// } | |
// return quicksort(left).concat(pivot, quicksort(right)); | |
// } | |
// console.log(quicksort([5, 2, 4, 8, 1, 7, 6, 3, 9])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment