{"action":"created","issue":{"url":"https://api.github.com/repos/FiguredLimited/vue-mc/issues/71","repository_url":"https://api.github.com/repos/FiguredLimited/vue-mc","labels_url":"https://api.github.com/repos/FiguredLimited/vue-mc/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/FiguredLimited/vue-mc/issues/71/comments","events_url":"https://api.github.com/repos/FiguredLimited/vue-mc/issues/71/events","html_url":"https://github.com/FiguredLimited/vue-mc/issues/71","id":354121229,"node_id":"MDU6SXNzdWUzNTQxMjEyMjk=","number":71,"title":"use sort() in template","user":{"login":"haayman","id":683823,"node_id":"MDQ6VXNlcjY4MzgyMw==","avatar_url":"https://avatars3.githubusercontent.com/u/683823?v=4","gravatar_id":"","url":"https://api.github.com/users/haayman","html_url":"https://github.com/haayman","followers_url":"https://api.github.com/users/haayman/followers","following_url":"https://api.github.com/users/haayman/following{/other_user}","gists_url":"https://api.github.com/users/haayman/gists{/gist_id}","starred_url":"https://api.github.com/users/haayman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haayman/subscriptions","organizations_url":"https://api.github.com/users/haayman/orgs","repos_url":"https://api.github.com/users/haayman/repos","events_url":"https://api.github.com/users/haayman/events{/privacy}","received_events_url":"https://api.github.com/users/haayman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-26T19:28:32Z","updated_at":"2018-08-27T19:37:56Z","closed_at":"2018-08-27T19:37:56Z","author_association":"NONE","body":"Hi,\r\n\r\nI've got this list of items that I want to be displayed in a certain sort order. I thought I'd use it in a template like:\r\n`<item v-for=\"item in itemList.models.sort('field')\"></item>`\r\nbut since sort() doesn't return anything this doesn't work\r\n\r\nI've 'solved' this by sorting anytime an item is added or when an item has changed. This way it's not possible to display the list twice in different sort orders. \r\n\r\nAny suggestions?"},"comment":{"url":"https://api.github.com/repos/FiguredLimited/vue-mc/issues/comments/416342910","html_url":"https://github.com/FiguredLimited/vue-mc/issues/71#issuecomment-416342910","issue_url":"https://api.github.com/repos/FiguredLimited/vue-mc/issues/71","id":416342910,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjM0MjkxMA==","user":{"login":"rtheunissen","id":809191,"node_id":"MDQ6VXNlcjgwOTE5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/809191?v=4","gravatar_id":"","url":"https://api.github.com/users/rtheunissen","html_url":"https://github.com/rtheunissen","followers_url":"https://api.github.com/users/rtheunissen/followers","following_url":"https://api.github.com/users/rtheunissen/following{/other_user}","gists_url":"https://api.github.com/users/rtheunissen/gists{/gist_id}","starred_url":"https://api.github.com/users/rtheunissen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtheunissen/subscriptions","organizations_url":"https://api.github.com/users/rtheunissen/orgs","repos_url":"https://api.github.com/users/rtheunissen/repos","events_url":"https://api.github.com/users/rtheunissen/events{/privacy}","received_events_url":"https://api.github.com/users/rtheunissen/received_events","type":"User","site_admin":false},"created_at":"2018-08-27T19:37:56Z","updated_at":"2018-08-27T19:37:56Z","author_association":"CONTRIBUTOR","body":"I think the best way to do this is to use a computed property or method with a sort type to produce a sorted version of the collection. For example,\r\n\r\n```js\r\n/**\r\n * @returns {Array}\r\n */\r\nitemsSortedBy(property) {\r\n    return _.sortBy(this.itemList.models, property);\r\n}\r\n\r\n/**\r\n * @returns {Array}\r\n */\r\nitemsSortedByName() {\r\n    return this.itemsSortedBy('name');\r\n}\r\n```\r\n\r\n```html\r\n<item v-for=\"item in itemsSortedByName\"></item>\r\n````"}}
{"actor":{"display_login":"rtheunissen"}}