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

[Feature] Add sort functions to standard library #614

Open
hdwalters opened this issue Nov 23, 2024 · 0 comments
Open

[Feature] Add sort functions to standard library #614

hdwalters opened this issue Nov 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@hdwalters
Copy link
Contributor

hdwalters commented Nov 23, 2024

Is your feature request related to a problem? Please describe.
The standard library is missing sorting functionality. This needs to be rectified.

Describe the solution you'd like
I suggest adding two functions to the array.ab file:

/// Sort the array in-place.
/// Pass `human` value `true` for human readable sort.
pub fun sort(ref array: [], human: Bool = false): Null {
    array = sorted(array)
}

/// Return the sorted array, leaving the original array unchanged.
/// Pass `human` value `true` for human readable sort.
pub fun sorted(array: [], human: Bool = false): [] {
    ...
}

Describe alternatives you've considered
N/A

Additional context
I suggest using the Bash sort command, with option -V for human readable sort. This reads standard input and writes standard output.

@hdwalters hdwalters added the enhancement New feature or request label Nov 23, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant