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

Add exporter option to sort exported items #160

Open
nichtich opened this issue Jun 26, 2015 · 3 comments
Open

Add exporter option to sort exported items #160

nichtich opened this issue Jun 26, 2015 · 3 comments

Comments

@nichtich
Copy link
Member

To sort items by a given field, e.g. sort by field creator.name or to sort reverse by numeric field size:

catmandu convert JSON to JSON --sort creator.name
catmandu convert JSON to JSON --rnsort size

I'd prefer four options sort, nsort, rsort, nrsort instead of sort, numerical and reverse but names can be discussed. Sorting would always imply buffering all items before export.

@phochste
Copy link
Member

Can in this case the sort in the to_array() feature be deleted? It would be a much cleaner to do something like:

 Catmandu->importer(...)->select(...)->sort(...)->to_array;

then

Catmandu->importer(...)->select(...)->to_array(sort => ....);

@nichtich
Copy link
Member Author

yes both features should be discussed together.

@nichtich
Copy link
Member Author

PR #161 implements $iterator->sort(...) without extended sorting options. I am not sure how to best express these options in the method and in the command line client. Possible options:

  • reverse
  • numeric
  • key (can be code reference to calculate key for Schwartzian transform, e.g. for keys expressed in fix path language)

In the CLI I'd prefer short names, such as --rsort ..., this could be alias to --reverse 1 --sort ..., right?

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

No branches or pull requests

2 participants