Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/sorts/quick-sort/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting function should take 2 arguments

  • array of elements
  • function comparator, to compare elements

module.exports = function quickSort(array) {
if (array.length === 0 || array.length < 2) {
return array;
Expand Down
1 change: 0 additions & 1 deletion lib/sorts/quick-sort/quick-sort.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const should = require('should');
const algo = require('../../index.js');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can your algorithm sort numbers less than 0?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you sort strings?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant you sort in descend order?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to your questions, my algorithm can sort numbers less than 0 and strings.
All necessary tests were added and passed.
But you are right it can't sort in the descend order.


Expand Down