{"action":"created","comment":{"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/comments/43017962","id":43017962,"diff_hunk":"@@ -17,11 +20,90 @@ module.exports.reverse = function () {\n \n // Оператор limit, который выбирает первые N записей\n module.exports.limit = function (n) {\n-    // Магия\n+    return function (collection) {\n+        var newCollection = collection.splice(0, n);\n+        return newCollection;\n+    };\n };\n \n // Вам необходимо реализовать остальные операторы:\n // select, filterIn, filterEqual, sortBy, format, limit\n \n+module.exports.select = function () {\n+    var args = [].slice.call(arguments);\n+    return function (collection) {\n+        var newCollection = [];\n+        collection.forEach(function (item, i, arr) {\n+            var contact = {};\n+            args.forEach(function (key, j, arr) {\n+                if (item[key]) {\n+                    contact[key] = item[key];\n+                }\n+            });\n+            newCollection.push(contact);\n+        });\n+        return newCollection;\n+    };\n+};\n+\n+module.exports.filterIn = function (filterKey, filterValue) {\n+    return function (collection) {\n+        var newCollection = [];\n+        collection.forEach(function (item, i, arr) {\n+            filterValue.forEach(function (value, i, arr) {\n+                if (value == item[filterKey]) {\n+                    newCollection.push(item);\n+                }\n+            });\n+        });\n+        return newCollection;\n+    };\n+};\n+\n+module.exports.filterEqual = function (filterKey, filterValue) {\n+    return function (collection) {\n+        return collection.filter(function (obj) {\n+            return (obj[filterKey] === filterValue) ? true : false;\n+        });\n+    };\n+};\n+\n+module.exports.sortBy = function (sortKey, sortingOrder) {\n+    return function (collection) {\n+        if (sortingOrder === 'asc') {\n+            collection.sort(function (a, b) {\n+                return sortValue(a, b, sortKey);\n+            });\n+        }\n+        if (sortingOrder === 'desc') {\n+            collection.sort(function (a, b) {\n+                return sortValue(b, a, sortKey);\n+            });","path":"lego.js","position":77,"original_position":77,"commit_id":"c8f294374d77ee9e04ac46efce0ff1f949818beb","original_commit_id":"c8f294374d77ee9e04ac46efce0ff1f949818beb","user":{"login":"dzlk","id":894822,"avatar_url":"https://avatars.githubusercontent.com/u/894822?v=3","gravatar_id":"","url":"https://api.github.com/users/dzlk","html_url":"https://github.com/dzlk","followers_url":"https://api.github.com/users/dzlk/followers","following_url":"https://api.github.com/users/dzlk/following{/other_user}","gists_url":"https://api.github.com/users/dzlk/gists{/gist_id}","starred_url":"https://api.github.com/users/dzlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzlk/subscriptions","organizations_url":"https://api.github.com/users/dzlk/orgs","repos_url":"https://api.github.com/users/dzlk/repos","events_url":"https://api.github.com/users/dzlk/events{/privacy}","received_events_url":"https://api.github.com/users/dzlk/received_events","type":"User","site_admin":false},"body":"все сильно проще:\r\n```js\r\nvar criteria = sortingOrder === 'asc' ? 1 : -1;\r\ncollection.sort(function (a, b) {\r\n    if (a[sortKey] > b[sortKey]) {\r\n        return criteria;\r\n    }\r\n    if (a[sortKey] < b[sortKey]) {\r\n        return -1 * criteria;\r\n    }\r\n    return 0;\r\n});\r\n```","created_at":"2015-10-26T16:39:58Z","updated_at":"2015-10-26T16:39:58Z","html_url":"https://github.com/urfu-2015/javascript-tasks-3/pull/28#discussion_r43017962","pull_request_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/comments/43017962"},"html":{"href":"https://github.com/urfu-2015/javascript-tasks-3/pull/28#discussion_r43017962"},"pull_request":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28","id":48034925,"html_url":"https://github.com/urfu-2015/javascript-tasks-3/pull/28","diff_url":"https://github.com/urfu-2015/javascript-tasks-3/pull/28.diff","patch_url":"https://github.com/urfu-2015/javascript-tasks-3/pull/28.patch","issue_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues/28","number":28,"state":"open","locked":false,"title":"Сухачев Илья","user":{"login":"lifeandfree","id":7126669,"avatar_url":"https://avatars.githubusercontent.com/u/7126669?v=3","gravatar_id":"","url":"https://api.github.com/users/lifeandfree","html_url":"https://github.com/lifeandfree","followers_url":"https://api.github.com/users/lifeandfree/followers","following_url":"https://api.github.com/users/lifeandfree/following{/other_user}","gists_url":"https://api.github.com/users/lifeandfree/gists{/gist_id}","starred_url":"https://api.github.com/users/lifeandfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifeandfree/subscriptions","organizations_url":"https://api.github.com/users/lifeandfree/orgs","repos_url":"https://api.github.com/users/lifeandfree/repos","events_url":"https://api.github.com/users/lifeandfree/events{/privacy}","received_events_url":"https://api.github.com/users/lifeandfree/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-19T06:24:21Z","updated_at":"2015-10-26T16:39:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1376d7999c61845db97e89ab9663fc77bf6693bb","assignee":{"login":"dzlk","id":894822,"avatar_url":"https://avatars.githubusercontent.com/u/894822?v=3","gravatar_id":"","url":"https://api.github.com/users/dzlk","html_url":"https://github.com/dzlk","followers_url":"https://api.github.com/users/dzlk/followers","following_url":"https://api.github.com/users/dzlk/following{/other_user}","gists_url":"https://api.github.com/users/dzlk/gists{/gist_id}","starred_url":"https://api.github.com/users/dzlk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzlk/subscriptions","organizations_url":"https://api.github.com/users/dzlk/orgs","repos_url":"https://api.github.com/users/dzlk/repos","events_url":"https://api.github.com/users/dzlk/events{/privacy}","received_events_url":"https://api.github.com/users/dzlk/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28/commits","review_comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28/comments","review_comment_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues/28/comments","statuses_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/statuses/c8f294374d77ee9e04ac46efce0ff1f949818beb","head":{"label":"lifeandfree:master","ref":"master","sha":"c8f294374d77ee9e04ac46efce0ff1f949818beb","user":{"login":"lifeandfree","id":7126669,"avatar_url":"https://avatars.githubusercontent.com/u/7126669?v=3","gravatar_id":"","url":"https://api.github.com/users/lifeandfree","html_url":"https://github.com/lifeandfree","followers_url":"https://api.github.com/users/lifeandfree/followers","following_url":"https://api.github.com/users/lifeandfree/following{/other_user}","gists_url":"https://api.github.com/users/lifeandfree/gists{/gist_id}","starred_url":"https://api.github.com/users/lifeandfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifeandfree/subscriptions","organizations_url":"https://api.github.com/users/lifeandfree/orgs","repos_url":"https://api.github.com/users/lifeandfree/repos","events_url":"https://api.github.com/users/lifeandfree/events{/privacy}","received_events_url":"https://api.github.com/users/lifeandfree/received_events","type":"User","site_admin":false},"repo":{"id":44508589,"name":"javascript-tasks-3","full_name":"lifeandfree/javascript-tasks-3","owner":{"login":"lifeandfree","id":7126669,"avatar_url":"https://avatars.githubusercontent.com/u/7126669?v=3","gravatar_id":"","url":"https://api.github.com/users/lifeandfree","html_url":"https://github.com/lifeandfree","followers_url":"https://api.github.com/users/lifeandfree/followers","following_url":"https://api.github.com/users/lifeandfree/following{/other_user}","gists_url":"https://api.github.com/users/lifeandfree/gists{/gist_id}","starred_url":"https://api.github.com/users/lifeandfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifeandfree/subscriptions","organizations_url":"https://api.github.com/users/lifeandfree/orgs","repos_url":"https://api.github.com/users/lifeandfree/repos","events_url":"https://api.github.com/users/lifeandfree/events{/privacy}","received_events_url":"https://api.github.com/users/lifeandfree/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lifeandfree/javascript-tasks-3","description":"Задача к лекции «Функции в Javascript» – «Картофельная вечеринка»","fork":true,"url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3","forks_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/forks","keys_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/teams","hooks_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/hooks","issue_events_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/issues/events{/number}","events_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/events","assignees_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/assignees{/user}","branches_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/branches{/branch}","tags_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/tags","blobs_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/statuses/{sha}","languages_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/languages","stargazers_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/stargazers","contributors_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/contributors","subscribers_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/subscribers","subscription_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/subscription","commits_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/contents/{+path}","compare_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/merges","archive_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/downloads","issues_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/issues{/number}","pulls_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/pulls{/number}","milestones_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/milestones{/number}","notifications_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/labels{/name}","releases_url":"https://api.github.com/repos/lifeandfree/javascript-tasks-3/releases{/id}","created_at":"2015-10-19T03:13:51Z","updated_at":"2015-10-19T03:13:52Z","pushed_at":"2015-10-26T12:08:00Z","git_url":"git://github.com/lifeandfree/javascript-tasks-3.git","ssh_url":"git@github.com:lifeandfree/javascript-tasks-3.git","clone_url":"https://github.com/lifeandfree/javascript-tasks-3.git","svn_url":"https://github.com/lifeandfree/javascript-tasks-3","homepage":"","size":93,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"urfu-2015:master","ref":"master","sha":"758f14fb6b73fe2ea3682a3cb7794dab5259d0f0","user":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"repo":{"id":44174808,"name":"javascript-tasks-3","full_name":"urfu-2015/javascript-tasks-3","owner":{"login":"urfu-2015","id":14800971,"avatar_url":"https://avatars.githubusercontent.com/u/14800971?v=3","gravatar_id":"","url":"https://api.github.com/users/urfu-2015","html_url":"https://github.com/urfu-2015","followers_url":"https://api.github.com/users/urfu-2015/followers","following_url":"https://api.github.com/users/urfu-2015/following{/other_user}","gists_url":"https://api.github.com/users/urfu-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/urfu-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urfu-2015/subscriptions","organizations_url":"https://api.github.com/users/urfu-2015/orgs","repos_url":"https://api.github.com/users/urfu-2015/repos","events_url":"https://api.github.com/users/urfu-2015/events{/privacy}","received_events_url":"https://api.github.com/users/urfu-2015/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urfu-2015/javascript-tasks-3","description":"Задача к лекции «Функции в Javascript» – «Картофельная вечеринка»","fork":false,"url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3","forks_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/forks","keys_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/teams","hooks_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/hooks","issue_events_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues/events{/number}","events_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/events","assignees_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/assignees{/user}","branches_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/branches{/branch}","tags_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/tags","blobs_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/git/refs{/sha}","trees_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/statuses/{sha}","languages_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/languages","stargazers_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/stargazers","contributors_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/contributors","subscribers_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/subscribers","subscription_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/subscription","commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/commits{/sha}","git_commits_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/git/commits{/sha}","comments_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/comments{/number}","issue_comment_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues/comments{/number}","contents_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/contents/{+path}","compare_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/merges","archive_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/downloads","issues_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues{/number}","pulls_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls{/number}","milestones_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/milestones{/number}","notifications_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/labels{/name}","releases_url":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/releases{/id}","created_at":"2015-10-13T12:30:10Z","updated_at":"2015-10-24T17:16:36Z","pushed_at":"2015-10-26T14:24:29Z","git_url":"git://github.com/urfu-2015/javascript-tasks-3.git","ssh_url":"git@github.com:urfu-2015/javascript-tasks-3.git","clone_url":"https://github.com/urfu-2015/javascript-tasks-3.git","svn_url":"https://github.com/urfu-2015/javascript-tasks-3","homepage":"","size":1607,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":79,"mirror_url":null,"open_issues_count":39,"forks":79,"open_issues":39,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28"},"html":{"href":"https://github.com/urfu-2015/javascript-tasks-3/pull/28"},"issue":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues/28"},"comments":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/urfu-2015/javascript-tasks-3/statuses/c8f294374d77ee9e04ac46efce0ff1f949818beb"}}}}