feat: implement custom sort method#2489
feat: implement custom sort method#2489wiliammunchen wants to merge 2 commits intomate-academy:masterfrom
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this task! I am approving your solution as it correctly implements the custom sort2 method and meets all requirements. Your code properly handles both default string-based comparisons and a user-provided compareFunction.
The bubble sort algorithm you chose is perfectly fine for this assignment. For future learning, you might consider exploring more efficient sorting algorithms like Quicksort or Merge Sort, which offer better performance on larger arrays.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
src/arrayMethodSort.js
Outdated
| for (let i = 0; i < this.length - 1; i++) { | ||
| for (let j = 0; j < this.length - 1 - i; j++) { | ||
| if (compare(this[j], this[j + 1]) > 0) { | ||
| const currentValue = this[j]; | ||
|
|
||
| this[j] = this[j + 1]; | ||
| this[j + 1] = currentValue; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This bubble sort implementation is correct and works well for this task. As a suggestion for future improvement, you could research more efficient sorting algorithms like Quicksort or Merge Sort. They offer better performance on larger arrays, which is a great topic to explore as you advance.
No description provided.