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 by key is not working #227

Closed
Ali-Dalal opened this issue May 15, 2020 · 1 comment
Closed

sort by key is not working #227

Ali-Dalal opened this issue May 15, 2020 · 1 comment

Comments

@Ali-Dalal
Copy link

does liquidjs support sorting by key?

example

  let data = {
        mydata: [
            {
                "count": 3,
                "label": "None"
            },
            {
                "count": 0,
                "label": "not bad"
            },
            {
                "count": 0,
                "label": "awesome"
            },
            {
                "count": 0,
                "label": "nice"
            },
            {
                "count": 9,
                "label": "cool"
            }
        ]
    }
    console.log(await engine.parseAndRender(`
    <h1>{% assign sorted = data.mydata | sort: "data.count" %}</h1>
    {%for row in sorted%}
        <h2>{{row.count}}</h2>
    {% endfor %}
    `, { data }))

the code throws an error
RenderError: The comparison function must be either a function or undefined, line:2, col:9

harttle added a commit that referenced this issue May 15, 2020
harttle pushed a commit that referenced this issue May 15, 2020
# [9.12.0](v9.11.11...v9.12.0) (2020-05-15)

### Features

* sort by key, see [#227](#227) ([4f17c94](4f17c94))
@Ali-Dalal
Copy link
Author

Ooooh, I just wanted to help you writing a fix for it. but you already did it. tested and working as expected. Thanks a lot

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