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

sort-within-records and regex: it seems not work #1645

Closed
aborruso opened this issue Sep 7, 2024 · 2 comments
Closed

sort-within-records and regex: it seems not work #1645

aborruso opened this issue Sep 7, 2024 · 2 comments
Assignees

Comments

@aborruso
Copy link
Contributor

aborruso commented Sep 7, 2024

Hi,
I have this input csv

a,12,2
z,x,c
4,5,t

If I run mlr --csv sort-within-records -r "[0-9]+" input.csv I get

12,2,a
x,c,z
5,t,4
mlr: open [0-9]+: no such file or directory.

It orders it, but I have in output also an error: "mlr: open [0-9]+: no such file or directory."

I take advantage of this for a feature request: I see that the sorting is done as if all the values were strings. Ideally, it would be great to add the option to sort by natural sorting and have the fields in the order 2,12,a.

Thank you

@johnkerl
Copy link
Owner

johnkerl commented Sep 8, 2024

@aborruso the -r option to sort-within-records isn't a regex match on field names:

$ mlr sort-within-records -h
Usage: mlr sort-within-records [options]
Outputs records sorted lexically ascending by keys.
Options:
-r        Recursively sort subobjects/submaps, e.g. for JSON input.
-h|--help Show this message.

Regardless, it would be nice to have a regex-match for field-name selection here.

@johnkerl johnkerl self-assigned this Sep 8, 2024
@aborruso aborruso closed this as completed Sep 9, 2024
@aborruso
Copy link
Contributor Author

aborruso commented Sep 9, 2024

Thank you

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