Skip to content

feat: implement custom sort method#2489

Open
wiliammunchen wants to merge 2 commits intomate-academy:masterfrom
wiliammunchen:master
Open

feat: implement custom sort method#2489
wiliammunchen wants to merge 2 commits intomate-academy:masterfrom
wiliammunchen:master

Conversation

@wiliammunchen
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

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

  1. Rate AI review example

Comment on lines +25 to +34
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;
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants