File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 11/**
2- * Quick sort is a comparison sorting algorithm that uses a divide and conquer strategy.
3- *
4- * For more information see here: https://en.wikipedia.org/wiki/Quicksort
5- */
6- export function quickSort ( items ) {
2+ * @function QuickSort
3+ * @description Quick sort is a comparison sorting algorithm that uses a divide and conquer strategy.
4+ * @param {Integer[] } items - Array of integers
5+ * @return {Integer[] } - Sorted array.
6+ * @see [QuickSort](https://en.wikipedia.org/wiki/Quicksort)
7+ */
8+ function quickSort ( items ) {
79 const length = items . length
810
911 if ( length <= 1 ) {
@@ -21,9 +23,8 @@ export function quickSort (items) {
2123 }
2224 }
2325
24- let sorted = quickSort ( LESSER )
25- sorted . push ( PIVOT )
26- sorted = sorted . concat ( quickSort ( GREATER ) )
27-
26+ const sorted = [ ...quickSort ( LESSER ) , PIVOT , ...quickSort ( GREATER ) ]
2827 return sorted
2928}
29+
30+ export { quickSort }
You can’t perform that action at this time.
0 commit comments