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 sortBy and reverse functions #431

Open
kit494way opened this issue Sep 27, 2024 · 0 comments
Open

Add sortBy and reverse functions #431

kit494way opened this issue Sep 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@kit494way
Copy link

Is your feature request related to a problem? Please describe.
I want to sort list of objects by key.
And, I want to reverse list.

Describe the solution you'd like
sortBy:

echo '[
    {
      "id": 1,
      "updatedAt": "2024-09-04T00:00:00+09:00"
    },
    {
      "id": 2,
      "updatedAt": "2024-09-03T00:00:00+09:00"
    }
  ]' | dasel -r json 'sortBy(updatedAt)'
[
  {
    "id": 2,
    "updatedAt": "2024-09-03T00:00:00+09:00"
  },
  {
    "id": 1,
    "updatedAt": "2024-09-04T00:00:00+09:00"
  }
]

reverse:

echo '[
    {
      "id": 1,
      "updatedAt": "2024-09-04T00:00:00+09:00"
    },
    {
      "id": 2,
      "updatedAt": "2024-09-03T00:00:00+09:00"
    }
  ]' | dasel -r json 'reverse()'
[
  {
    "id": 2,
    "updatedAt": "2024-09-03T00:00:00+09:00"
  },
  {
    "id": 1,
    "updatedAt": "2024-09-04T00:00:00+09:00"
  }
]

Describe alternatives you've considered
nothing.

Additional context
sortBy is referred to in the discussion here.

@kit494way kit494way added the enhancement New feature or request label Sep 27, 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