Skip to content

Commit 952c92d

Browse files
authored
Added the Javascript implementation
Added the Javascript implementation of quick sort
1 parent 989cbc7 commit 952c92d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

QuickSort/Javascript

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function quickSort(items, left, right) {
2+
3+
var index;
4+
5+
if (items.length > 1) {
6+
7+
left = typeof left != "number" ? 0 : left;
8+
right = typeof right != "number" ? items.length - 1 : right;
9+
10+
index = partition(items, left, right);
11+
12+
if (left < index - 1) {
13+
quickSort(items, left, index - 1);
14+
}
15+
16+
if (index < right) {
17+
quickSort(items, index, right);
18+
}
19+
20+
}
21+
22+
return items;
23+
}
24+
25+
// first call
26+
var result = quickSort(items);

0 commit comments

Comments
 (0)