Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sort method to array/fixed-endian-factory #3298

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

ahmad-kashkoush
Copy link
Contributor

Resolves #3156

Description

What is the purpose of this pull request?

This pull request:

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?
Do you prefer squashing all commits into a single one after finishing, or keeping it as here is better?

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@stdlib-bot
Copy link
Contributor

stdlib-bot commented Nov 29, 2024

Coverage Report

Package Statements Branches Functions Lines
array/fixed-endian-factory $\color{red}1222/1472$
$\color{green}+83.02\%$
$\color{red}168/180$
$\color{green}+93.33\%$
$\color{red}25/34$
$\color{green}+73.53\%$
$\color{red}1222/1472$
$\color{green}+83.02\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte added Feature Issue or pull request for adding a new feature. Needs Review A pull request which needs code review. labels Dec 3, 2024
throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );
}
buf = this._buffer;
for ( i = 0; i < this._length-1; i++ ) {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than a hand-rolled sort implementation, just copy to a temporary buffer (e.g., a plain array), use the built-in sort, and then copy back to the original buffer. That will be 2N + N log N, which is still better than N^2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll update it

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Dec 3, 2024
@ahmad-kashkoush
Copy link
Contributor Author

@kgryte May you give it one more review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Issue or pull request for adding a new feature. Needs Changes Pull request which needs changes before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add sort method to array/fixed-endian-factory
3 participants