8000 Add `sortBy` and `reverse` functions · Issue #431 · TomWright/dasel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add sortBy and reverse functions #431
Open
@kit494way

Description

@kit494way

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0