{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/85633188","pull_request_review_id":6341320,"id":85633188,"diff_hunk":"@@ -0,0 +1,289 @@\n+package formatter\n+\n+import (\n+\t\"fmt\"\n+\t\"reflect\"\n+\t\"strings\"\n+\t\"time\"\n+)\n+\n+type genericStructSorter struct {\n+\tdata     []interface{}\n+\tbys      []string\n+\tordering []string\n+\tindexes  [][]int\n+}\n+\n+func (s genericStructSorter) Len() int {\n+\treturn len(s.data)\n+}\n+\n+func (s genericStructSorter) Swap(i, j int) {\n+\ts.data[i], s.data[j] = s.data[j], s.data[i]\n+}\n+\n+const (\n+\tascendantKey  = \"asc\"\n+\tdescendantKey = \"dsc\"\n+)\n+\n+func validateType(i interface{}, j interface{}) error {\n+\tiType := reflect.TypeOf(i)\n+\tjType := reflect.TypeOf(j)\n+\tif iType.Kind() != reflect.Struct {\n+\t\treturn fmt.Errorf(\"data must be of type struct\")\n+\t}\n+\tif iType.PkgPath() != jType.PkgPath() || iType.Name() != jType.Name() || iType.Kind() != jType.Kind() {\n+\t\treturn fmt.Errorf(\"data are not of the same type: (%v, %v, %v) != (%v, %v, %v)\",\n+\t\t\tiType.PkgPath(), iType.Name(), iType.Kind(), jType.PkgPath(), jType.Name(), jType.Kind())\n+\t}\n+\treturn nil\n+}\n+\n+func findFieldIndex(t reflect.Type, name string, index *[]int) bool {\n+\tmatch := func(s string) bool {\n+\t\treturn strings.EqualFold(s, name)\n+\t}\n+\tf, ok := t.FieldByNameFunc(match)\n+\tif ok {\n+\t\t*index = append(f.Index, *index...)\n+\t\treturn true\n+\t}\n+\n+\tfor i := 0; i < t.NumField(); i++ {\n+\t\tnt := t.Field(i).Type\n+\t\tif t.Kind() == reflect.Ptr {\n+\t\t\tnt = nt.Elem()\n+\t\t}\n+\t\tif nt.Kind() == reflect.Struct {\n+\t\t\tok = findFieldIndex(nt, name, index)","path":"cli/command/formatter/sorter.go","position":59,"original_position":59,"commit_id":"13fea9067cfa2ad6bc464a1ad025750de09ab525","original_commit_id":"13fea9067cfa2ad6bc464a1ad025750de09ab525","user":{"login":"WeiZhang555","id":1203611,"avatar_url":"https://avatars.githubusercontent.com/u/1203611?v=3","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"body":"This part is written by @mlaventure , but I agree with his implementation, I think we'd better keep this, as the image related structures are complicated. \r\nRight now, it works well for me, I can get what I want. ","created_at":"2016-10-29T03:51:03Z","updated_at":"2016-10-29T03:51:04Z","html_url":"https://github.com/docker/docker/pull/25702#discussion_r85633188","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/25702","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/85633188"},"html":{"href":"https://github.com/docker/docker/pull/25702#discussion_r85633188"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/25702"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/25702","id":81287798,"html_url":"https://github.com/docker/docker/pull/25702","diff_url":"https://github.com/docker/docker/pull/25702.diff","patch_url":"https://github.com/docker/docker/pull/25702.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/25702","number":25702,"state":"open","locked":false,"title":"Enhancement: add --sort-by flag for images command","user":{"login":"WeiZhang555","id":1203611,"avatar_url":"https://avatars.githubusercontent.com/u/1203611?v=3","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"body":"Part of #25609\r\n\r\nAllow user to customize their favourite list order, user can choose to\r\nsort images by e.g. \"size\" in \"asc\"/\"des\" order.\r\n\r\nUsage: --sort-by field[:order]\r\n\r\nSupported fields:\r\n* \"repo\": sort by repository:tags.\r\n* \"created\": sort by created time.\r\n* \"size\": sort by image size.\r\n\r\norder can be either \"asc\" or \"des\", which means sort in ascent/descent\r\norders, default is \"asc\" if not specified.\r\n\r\nSample Usage: \"--sort-by size:des\"\r\n\r\nSigned-off-by: Zhang Wei <zhangwei555@huawei.com>\r\n\r\nThis is more like a prototype, I'd like to hear more feedbacks before I started to write test cases. :smile: ","created_at":"2016-08-15T09:16:33Z","updated_at":"2016-10-29T03:51:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f48c51240c0f434c24fcb9737c3f9e20a0f74e26","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/25702/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/25702/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/25702/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/13fea9067cfa2ad6bc464a1ad025750de09ab525","head":{"label":"WeiZhang555:sort-image","ref":"sort-image","sha":"13fea9067cfa2ad6bc464a1ad025750de09ab525","user":{"login":"WeiZhang555","id":1203611,"avatar_url":"https://avatars.githubusercontent.com/u/1203611?v=3","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"repo":{"id":29129000,"name":"docker","full_name":"WeiZhang555/docker","owner":{"login":"WeiZhang555","id":1203611,"avatar_url":"https://avatars.githubusercontent.com/u/1203611?v=3","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/WeiZhang555/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/WeiZhang555/docker","forks_url":"https://api.github.com/repos/WeiZhang555/docker/forks","keys_url":"https://api.github.com/repos/WeiZhang555/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WeiZhang555/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WeiZhang555/docker/teams","hooks_url":"https://api.github.com/repos/WeiZhang555/docker/hooks","issue_events_url":"https://api.github.com/repos/WeiZhang555/docker/issues/events{/number}","events_url":"https://api.github.com/repos/WeiZhang555/docker/events","assignees_url":"https://api.github.com/repos/WeiZhang555/docker/assignees{/user}","branches_url":"https://api.github.com/repos/WeiZhang555/docker/branches{/branch}","tags_url":"https://api.github.com/repos/WeiZhang555/docker/tags","blobs_url":"https://api.github.com/repos/WeiZhang555/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WeiZhang555/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WeiZhang555/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/WeiZhang555/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WeiZhang555/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/WeiZhang555/docker/languages","stargazers_url":"https://api.github.com/repos/WeiZhang555/docker/stargazers","contributors_url":"https://api.github.com/repos/WeiZhang555/docker/contributors","subscribers_url":"https://api.github.com/repos/WeiZhang555/docker/subscribers","subscription_url":"https://api.github.com/repos/WeiZhang555/docker/subscription","commits_url":"https://api.github.com/repos/WeiZhang555/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/WeiZhang555/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/WeiZhang555/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/WeiZhang555/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/WeiZhang555/docker/contents/{+path}","compare_url":"https://api.github.com/repos/WeiZhang555/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WeiZhang555/docker/merges","archive_url":"https://api.github.com/repos/WeiZhang555/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WeiZhang555/docker/downloads","issues_url":"https://api.github.com/repos/WeiZhang555/docker/issues{/number}","pulls_url":"https://api.github.com/repos/WeiZhang555/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/WeiZhang555/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/WeiZhang555/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WeiZhang555/docker/labels{/name}","releases_url":"https://api.github.com/repos/WeiZhang555/docker/releases{/id}","deployments_url":"https://api.github.com/repos/WeiZhang555/docker/deployments","created_at":"2015-01-12T09:50:32Z","updated_at":"2016-01-26T07:59:14Z","pushed_at":"2016-10-25T03:45:46Z","git_url":"git://github.com/WeiZhang555/docker.git","ssh_url":"git@github.com:WeiZhang555/docker.git","clone_url":"https://github.com/WeiZhang555/docker.git","svn_url":"https://github.com/WeiZhang555/docker","homepage":"http://www.docker.com","size":104169,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"f901c5ed1c76d507a09079935e680f8c5bdd9070","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","deployments_url":"https://api.github.com/repos/docker/docker/deployments","created_at":"2013-01-18T18:10:57Z","updated_at":"2016-10-29T03:37:39Z","pushed_at":"2016-10-29T02:30:40Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":216264,"stargazers_count":36384,"watchers_count":36384,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10740,"mirror_url":null,"open_issues_count":1903,"forks":10740,"open_issues":1903,"watchers":36384,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/25702"},"html":{"href":"https://github.com/docker/docker/pull/25702"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/25702"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/25702/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/25702/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/25702/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/13fea9067cfa2ad6bc464a1ad025750de09ab525"}}}}
{"actor":{"display_login":"WeiZhang555"}}