{"action":"created","comment":{"url":"https://api.github.com/repos/emberjs/rfcs/pulls/comments/38086046","id":38086046,"diff_hunk":"@@ -0,0 +1,66 @@\n+- Start Date: 2015-08-26\n+- RFC PR: (leave this empty)\n+- Ember Issue: (leave this empty)\n+\n+# Summary\n+\n+In Ember 2.x, `Ember.computed.sort` is the one and only computed macro for sorting a list. Its current API is built assuming that the sort order may change at runtime, leaving no way to easily create a declarative sort macro that you know is immutable. This RFC proposes adding an additional argument type for the `sortDefinition` parameter to make it easier to declare and to ensure sort order is immutable.\n+\n+# Motivation\n+\n+I'm hoping to satisfy two primary annoyances with this RFC. First, `Ember.computed.sort` can be used as a singular definition as the sort order will be the value of the second argument, you will not have to look for another definition on the class, thus improving code readability. In our app, we often have the following:\n+\n+```javascript\n+var NewestPostsController = Ember.Controller.extend({\n+  posts: null,\n+  newestPosts: Ember.computed.sort('posts', '_newestPostsOrder'),\n+  _newestPostsOrder: ['createdOn:desc']\n+});\n+```\n+\n+The second annoyance is I know that if `_newestPostsOrder` was inadvertently changed, it could cause `newestPosts` to be incorrect. I realize this would just be a bug in our app, but having the ability to define an immutable sort order would give the same peace of mind as a readOnly computed property.\n+\n+# Detailed design\n+\n+Right now the second argument for `Ember.computed.sort`, `sortDefinition`, accepts two values, a string and a function. I'm proposing we add array as a third allowed argument type. The array would expect the exact same sort properties format as it does when using a string as a dependent key. Reusing the above example,\n+\n+Before:\n+```javascript\n+var NewestPostsController = Ember.Controller.extend({\n+  posts: null,\n+  newestPosts: Ember.computed.sort('posts', '_newestPostsOrder'),\n+  _newestPostsOrder: ['createdOn:desc']\n+});\n+```\n+\n+After:\n+```javascript\n+var NewestPostsController = Ember.Controller.extend({\n+  posts: null,\n+  newestPosts: Ember.computed.sort('posts', ['createdOn:desc'])\n+});\n+```\n+\n+This design would not break semver as it's an additional argument type that was previously not supported.\n+\n+# Drawbacks\n+\n+I can think of two drawbacks. First and foremost, the array argument type will become reserved for this functionality. It could not easily be reused for a new extension in the future. Second, it's ultimately just a more convenient way of doing something that is already functionally possible.\n+\n+# Alternatives\n+\n+An alternative would be to implement a new computed macro called: `Ember.computed.sortBy`. This would allow for more argument/API flexibility. Here a few examples:\n+\n+```javascript\n+newestPosts: Ember.computed.sortBy('posts', 'createdOn') # default to ascending","path":"active/0000-computed-sort-array-argument.md","position":55,"original_position":55,"commit_id":"bfa15324ee5e613e274fd7dad228465a6169f1cf","original_commit_id":"bfa15324ee5e613e274fd7dad228465a6169f1cf","user":{"login":"workmanw","id":825487,"avatar_url":"https://avatars.githubusercontent.com/u/825487?v=3","gravatar_id":"","url":"https://api.github.com/users/workmanw","html_url":"https://github.com/workmanw","followers_url":"https://api.github.com/users/workmanw/followers","following_url":"https://api.github.com/users/workmanw/following{/other_user}","gists_url":"https://api.github.com/users/workmanw/gists{/gist_id}","starred_url":"https://api.github.com/users/workmanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/workmanw/subscriptions","organizations_url":"https://api.github.com/users/workmanw/orgs","repos_url":"https://api.github.com/users/workmanw/repos","events_url":"https://api.github.com/users/workmanw/events{/privacy}","received_events_url":"https://api.github.com/users/workmanw/received_events","type":"User","site_admin":false},"body":"Hahaha. My brain didn't even notice. :)","created_at":"2015-08-27T11:43:28Z","updated_at":"2015-08-27T11:43:28Z","html_url":"https://github.com/emberjs/rfcs/pull/87#discussion_r38086046","pull_request_url":"https://api.github.com/repos/emberjs/rfcs/pulls/87","_links":{"self":{"href":"https://api.github.com/repos/emberjs/rfcs/pulls/comments/38086046"},"html":{"href":"https://github.com/emberjs/rfcs/pull/87#discussion_r38086046"},"pull_request":{"href":"https://api.github.com/repos/emberjs/rfcs/pulls/87"}}},"pull_request":{"url":"https://api.github.com/repos/emberjs/rfcs/pulls/87","id":43397901,"html_url":"https://github.com/emberjs/rfcs/pull/87","diff_url":"https://github.com/emberjs/rfcs/pull/87.diff","patch_url":"https://github.com/emberjs/rfcs/pull/87.patch","issue_url":"https://api.github.com/repos/emberjs/rfcs/issues/87","number":87,"state":"open","locked":false,"title":"RFC to make Ember.computed.sort more convenient for some use cases.","user":{"login":"workmanw","id":825487,"avatar_url":"https://avatars.githubusercontent.com/u/825487?v=3","gravatar_id":"","url":"https://api.github.com/users/workmanw","html_url":"https://github.com/workmanw","followers_url":"https://api.github.com/users/workmanw/followers","following_url":"https://api.github.com/users/workmanw/following{/other_user}","gists_url":"https://api.github.com/users/workmanw/gists{/gist_id}","starred_url":"https://api.github.com/users/workmanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/workmanw/subscriptions","organizations_url":"https://api.github.com/users/workmanw/orgs","repos_url":"https://api.github.com/users/workmanw/repos","events_url":"https://api.github.com/users/workmanw/events{/privacy}","received_events_url":"https://api.github.com/users/workmanw/received_events","type":"User","site_admin":false},"body":"[Rendered](https://github.com/workmanw/rfcs/blob/computed-sort-array-argument/active/0000-computed-sort-array-argument.md)\r\n\r\nIt's not really a big RFC. Happy to add any further detail, I just didn't want to draw it out when it was straight forward. ","created_at":"2015-08-26T12:52:30Z","updated_at":"2015-08-27T11:43:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea2e8699dd3678f5cc5fb7c5ff030a5ee38a683d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/emberjs/rfcs/pulls/87/commits","review_comments_url":"https://api.github.com/repos/emberjs/rfcs/pulls/87/comments","review_comment_url":"https://api.github.com/repos/emberjs/rfcs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/emberjs/rfcs/issues/87/comments","statuses_url":"https://api.github.com/repos/emberjs/rfcs/statuses/bfa15324ee5e613e274fd7dad228465a6169f1cf","head":{"label":"workmanw:computed-sort-array-argument","ref":"computed-sort-array-argument","sha":"bfa15324ee5e613e274fd7dad228465a6169f1cf","user":{"login":"workmanw","id":825487,"avatar_url":"https://avatars.githubusercontent.com/u/825487?v=3","gravatar_id":"","url":"https://api.github.com/users/workmanw","html_url":"https://github.com/workmanw","followers_url":"https://api.github.com/users/workmanw/followers","following_url":"https://api.github.com/users/workmanw/following{/other_user}","gists_url":"https://api.github.com/users/workmanw/gists{/gist_id}","starred_url":"https://api.github.com/users/workmanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/workmanw/subscriptions","organizations_url":"https://api.github.com/users/workmanw/orgs","repos_url":"https://api.github.com/users/workmanw/repos","events_url":"https://api.github.com/users/workmanw/events{/privacy}","received_events_url":"https://api.github.com/users/workmanw/received_events","type":"User","site_admin":false},"repo":{"id":23994284,"name":"rfcs","full_name":"workmanw/rfcs","owner":{"login":"workmanw","id":825487,"avatar_url":"https://avatars.githubusercontent.com/u/825487?v=3","gravatar_id":"","url":"https://api.github.com/users/workmanw","html_url":"https://github.com/workmanw","followers_url":"https://api.github.com/users/workmanw/followers","following_url":"https://api.github.com/users/workmanw/following{/other_user}","gists_url":"https://api.github.com/users/workmanw/gists{/gist_id}","starred_url":"https://api.github.com/users/workmanw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/workmanw/subscriptions","organizations_url":"https://api.github.com/users/workmanw/orgs","repos_url":"https://api.github.com/users/workmanw/repos","events_url":"https://api.github.com/users/workmanw/events{/privacy}","received_events_url":"https://api.github.com/users/workmanw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/workmanw/rfcs","description":"RFCs for changes to Ember","fork":true,"url":"https://api.github.com/repos/workmanw/rfcs","forks_url":"https://api.github.com/repos/workmanw/rfcs/forks","keys_url":"https://api.github.com/repos/workmanw/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/workmanw/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/workmanw/rfcs/teams","hooks_url":"https://api.github.com/repos/workmanw/rfcs/hooks","issue_events_url":"https://api.github.com/repos/workmanw/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/workmanw/rfcs/events","assignees_url":"https://api.github.com/repos/workmanw/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/workmanw/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/workmanw/rfcs/tags","blobs_url":"https://api.github.com/repos/workmanw/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/workmanw/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/workmanw/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/workmanw/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/workmanw/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/workmanw/rfcs/languages","stargazers_url":"https://api.github.com/repos/workmanw/rfcs/stargazers","contributors_url":"https://api.github.com/repos/workmanw/rfcs/contributors","subscribers_url":"https://api.github.com/repos/workmanw/rfcs/subscribers","subscription_url":"https://api.github.com/repos/workmanw/rfcs/subscription","commits_url":"https://api.github.com/repos/workmanw/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/workmanw/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/workmanw/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/workmanw/rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/workmanw/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/workmanw/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/workmanw/rfcs/merges","archive_url":"https://api.github.com/repos/workmanw/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/workmanw/rfcs/downloads","issues_url":"https://api.github.com/repos/workmanw/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/workmanw/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/workmanw/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/workmanw/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/workmanw/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/workmanw/rfcs/releases{/id}","created_at":"2014-09-13T12:56:09Z","updated_at":"2014-09-08T19:03:30Z","pushed_at":"2015-08-26T19:58:38Z","git_url":"git://github.com/workmanw/rfcs.git","ssh_url":"git@github.com:workmanw/rfcs.git","clone_url":"https://github.com/workmanw/rfcs.git","svn_url":"https://github.com/workmanw/rfcs","homepage":null,"size":111,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"emberjs:master","ref":"master","sha":"7c43fb49b98e2e1c7f26a97f9d0475f8db8a089e","user":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars.githubusercontent.com/u/1253363?v=3","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"repo":{"id":22664562,"name":"rfcs","full_name":"emberjs/rfcs","owner":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars.githubusercontent.com/u/1253363?v=3","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/emberjs/rfcs","description":"RFCs for changes to Ember","fork":false,"url":"https://api.github.com/repos/emberjs/rfcs","forks_url":"https://api.github.com/repos/emberjs/rfcs/forks","keys_url":"https://api.github.com/repos/emberjs/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emberjs/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emberjs/rfcs/teams","hooks_url":"https://api.github.com/repos/emberjs/rfcs/hooks","issue_events_url":"https://api.github.com/repos/emberjs/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/emberjs/rfcs/events","assignees_url":"https://api.github.com/repos/emberjs/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/emberjs/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/emberjs/rfcs/tags","blobs_url":"https://api.github.com/repos/emberjs/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emberjs/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emberjs/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/emberjs/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emberjs/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/emberjs/rfcs/languages","stargazers_url":"https://api.github.com/repos/emberjs/rfcs/stargazers","contributors_url":"https://api.github.com/repos/emberjs/rfcs/contributors","subscribers_url":"https://api.github.com/repos/emberjs/rfcs/subscribers","subscription_url":"https://api.github.com/repos/emberjs/rfcs/subscription","commits_url":"https://api.github.com/repos/emberjs/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/emberjs/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/emberjs/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/emberjs/rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/emberjs/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/emberjs/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emberjs/rfcs/merges","archive_url":"https://api.github.com/repos/emberjs/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emberjs/rfcs/downloads","issues_url":"https://api.github.com/repos/emberjs/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/emberjs/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/emberjs/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/emberjs/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emberjs/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/emberjs/rfcs/releases{/id}","created_at":"2014-08-06T00:49:22Z","updated_at":"2015-08-27T10:53:10Z","pushed_at":"2015-08-26T19:58:38Z","git_url":"git://github.com/emberjs/rfcs.git","ssh_url":"git@github.com:emberjs/rfcs.git","clone_url":"https://github.com/emberjs/rfcs.git","svn_url":"https://github.com/emberjs/rfcs","homepage":null,"size":978,"stargazers_count":333,"watchers_count":333,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":80,"mirror_url":null,"open_issues_count":36,"forks":80,"open_issues":36,"watchers":333,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/emberjs/rfcs/pulls/87"},"html":{"href":"https://github.com/emberjs/rfcs/pull/87"},"issue":{"href":"https://api.github.com/repos/emberjs/rfcs/issues/87"},"comments":{"href":"https://api.github.com/repos/emberjs/rfcs/issues/87/comments"},"review_comments":{"href":"https://api.github.com/repos/emberjs/rfcs/pulls/87/comments"},"review_comment":{"href":"https://api.github.com/repos/emberjs/rfcs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/emberjs/rfcs/pulls/87/commits"},"statuses":{"href":"https://api.github.com/repos/emberjs/rfcs/statuses/bfa15324ee5e613e274fd7dad228465a6169f1cf"}}}}