Created
January 18, 2019 08:21
-
-
Save ger86/b94d5ba92e667bb631a745b8cf297723 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const testA = [9, -3, 5, 2, 6, 8, -6, 1, 3]; | |
| const testASorted = quickSort(testA); | |
| console.log(testASorted); | |
| const testB = [-3, -2, -1, 0, 1, 2, 3]; | |
| const testBSorted = quickSort(testB); | |
| console.log(testBSorted); | |
| const testC = [3, 2, 1, 0, -1, -2, -3]; | |
| const testCSorted = quickSort(testC); | |
| console.log(testCSorted); | |
| const testD = [ | |
| { | |
| id: 9, | |
| name: "Task 9" | |
| }, | |
| { | |
| id: -1, | |
| name: "Task -1" | |
| }, | |
| { | |
| id: 5, | |
| name: "Task 5" | |
| }, | |
| { | |
| id: 3, | |
| name: "Task 3" | |
| }, | |
| { | |
| id: -10, | |
| name: "Task -10" | |
| } | |
| ]; | |
| const testDSorted = quickSort(testD, (a, b) => { | |
| if (a.id < b.id) { | |
| return -1; | |
| } | |
| if (a.id > b.id) { | |
| return 1; | |
| } | |
| return 0; | |
| }); | |
| console.log(testDSorted); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment