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

Array sorting #1112

Open
lue-bird opened this issue May 28, 2021 · 2 comments
Open

Array sorting #1112

lue-bird opened this issue May 28, 2021 · 2 comments

Comments

@lue-bird
Copy link

lue-bird commented May 28, 2021

Sorting operations like sort, sortBy & sortWith in List can't be found in the module Array.
I miss them the most when working with Arrays, so I think these would be worth adding in a future release to supply a default way of sorting Arrays.

@github-actions
Copy link

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

@andre-dietrich
Copy link

Hi, this would be a great feature. It seems to me, that the functionality is already there, since the array seems to be used for sorting lists. It only needs to be exposed also to the array module. I think something like this could also be relevant to create more performant statistics libraries ...

var _List_sortBy = F2(function(f, xs)
{
return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
return __Utils_cmp(f(a), f(b));
}));
});
var _List_sortWith = F2(function(f, xs)
{
return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
var ord = A2(f, a, b);
return ord === __Basics_EQ ? 0 : ord === __Basics_LT ? -1 : 1;
}));
});

@lue-bird lue-bird changed the title sorting arrays Array sorting Aug 8, 2022
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

No branches or pull requests

2 participants