{"action":"closed","number":26,"pull_request":{"url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/26","id":52808963,"html_url":"https://github.com/sudocrystal/cs-fundamentals/pull/26","diff_url":"https://github.com/sudocrystal/cs-fundamentals/pull/26.diff","patch_url":"https://github.com/sudocrystal/cs-fundamentals/pull/26.patch","issue_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues/26","number":26,"state":"closed","locked":false,"title":"Comments on sorting","user":{"login":"lacuchilla","id":5484041,"avatar_url":"https://avatars.githubusercontent.com/u/5484041?v=3","gravatar_id":"","url":"https://api.github.com/users/lacuchilla","html_url":"https://github.com/lacuchilla","followers_url":"https://api.github.com/users/lacuchilla/followers","following_url":"https://api.github.com/users/lacuchilla/following{/other_user}","gists_url":"https://api.github.com/users/lacuchilla/gists{/gist_id}","starred_url":"https://api.github.com/users/lacuchilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lacuchilla/subscriptions","organizations_url":"https://api.github.com/users/lacuchilla/orgs","repos_url":"https://api.github.com/users/lacuchilla/repos","events_url":"https://api.github.com/users/lacuchilla/events{/privacy}","received_events_url":"https://api.github.com/users/lacuchilla/received_events","type":"User","site_admin":false},"body":"Insertion sort\r\n\r\nInsertion sort removes one element from the input data, finds the location it belongs within the sorted list and inserts it there. It repeats until no input elements remain. In this code, first we set a variable equal to zero for it to be used as a placeholder for the current element in the iteration as we compare all of the elements in the array. We use i as the initial iteration variable. Because arrays are zero indexed, we need to take the length of the array and subtract 1 to determine the index number of the last spot in the array. Next we set two variables, j becomes the current value of i and we set a boolean in the variable done to false. We will then iterate through the array using a while loop and once the array has been sorted, done will be set to true and the loop will end. So, while j (the number in the current iteration) is greater than zero and the done variable is set to false, we first look at the number compare variable and add 1 to it. If the number in the jth position of the array is less than the number in the jth position of the array -1, we decrement the number currently saved in j by 1 and use that as the index number for the current position array. Then we take the j -1 position of the array and set it to the jth position of the array, and then save the value in the temporary variable and assign it to arr[j]. Once this has taken place with all of the numbers in the array, the done variable is set to true,  j is then set to j -1 and the loop completes and the sorted array is returned.\r\n\r\nSelection sort\r\n\r\nSelection sort compares the entire array for the smallest item and moves it to the first position in the list. Then it searches for the smallest item from the second position to the end of the list and moves that value to the second position and so on and so forth until the entire array is sorted. The values are switched. For each element i in the array range from 0 to the length of the array - 2, we set that value to the minimum_index variable. Inside of that loop we take each element j from the range of i + 1 to the length of the array -1. If the value stored in j is less than the value stored in minimum_index, the value in j becomes the new value of minimum_index, then we swap the value in i for the value in minimum_index.","created_at":"2015-12-07T06:12:29Z","updated_at":"2015-12-14T08:07:59Z","closed_at":"2015-12-14T08:07:59Z","merged_at":null,"merge_commit_sha":"e1d56e1bdafba4358a49cf580f8f2d6f7e2e73b1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/26/commits","review_comments_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/26/comments","review_comment_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues/26/comments","statuses_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/statuses/88379e4350605214467f41518a2a7389a8b5699e","head":{"label":"lacuchilla:patch-1","ref":"patch-1","sha":"88379e4350605214467f41518a2a7389a8b5699e","user":{"login":"lacuchilla","id":5484041,"avatar_url":"https://avatars.githubusercontent.com/u/5484041?v=3","gravatar_id":"","url":"https://api.github.com/users/lacuchilla","html_url":"https://github.com/lacuchilla","followers_url":"https://api.github.com/users/lacuchilla/followers","following_url":"https://api.github.com/users/lacuchilla/following{/other_user}","gists_url":"https://api.github.com/users/lacuchilla/gists{/gist_id}","starred_url":"https://api.github.com/users/lacuchilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lacuchilla/subscriptions","organizations_url":"https://api.github.com/users/lacuchilla/orgs","repos_url":"https://api.github.com/users/lacuchilla/repos","events_url":"https://api.github.com/users/lacuchilla/events{/privacy}","received_events_url":"https://api.github.com/users/lacuchilla/received_events","type":"User","site_admin":false},"repo":{"id":46250294,"name":"cs-fundamentals","full_name":"lacuchilla/cs-fundamentals","owner":{"login":"lacuchilla","id":5484041,"avatar_url":"https://avatars.githubusercontent.com/u/5484041?v=3","gravatar_id":"","url":"https://api.github.com/users/lacuchilla","html_url":"https://github.com/lacuchilla","followers_url":"https://api.github.com/users/lacuchilla/followers","following_url":"https://api.github.com/users/lacuchilla/following{/other_user}","gists_url":"https://api.github.com/users/lacuchilla/gists{/gist_id}","starred_url":"https://api.github.com/users/lacuchilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lacuchilla/subscriptions","organizations_url":"https://api.github.com/users/lacuchilla/orgs","repos_url":"https://api.github.com/users/lacuchilla/repos","events_url":"https://api.github.com/users/lacuchilla/events{/privacy}","received_events_url":"https://api.github.com/users/lacuchilla/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lacuchilla/cs-fundamentals","description":"CS Fundamentals Series","fork":true,"url":"https://api.github.com/repos/lacuchilla/cs-fundamentals","forks_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/forks","keys_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/teams","hooks_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/hooks","issue_events_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/issues/events{/number}","events_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/events","assignees_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/assignees{/user}","branches_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/branches{/branch}","tags_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/tags","blobs_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/git/refs{/sha}","trees_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/statuses/{sha}","languages_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/languages","stargazers_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/stargazers","contributors_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/contributors","subscribers_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/subscribers","subscription_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/subscription","commits_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/commits{/sha}","git_commits_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/git/commits{/sha}","comments_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/comments{/number}","issue_comment_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/issues/comments{/number}","contents_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/contents/{+path}","compare_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/merges","archive_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/downloads","issues_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/issues{/number}","pulls_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/pulls{/number}","milestones_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/milestones{/number}","notifications_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/labels{/name}","releases_url":"https://api.github.com/repos/lacuchilla/cs-fundamentals/releases{/id}","created_at":"2015-11-16T03:40:07Z","updated_at":"2015-11-16T03:40:08Z","pushed_at":"2015-12-14T04:22:15Z","git_url":"git://github.com/lacuchilla/cs-fundamentals.git","ssh_url":"git@github.com:lacuchilla/cs-fundamentals.git","clone_url":"https://github.com/lacuchilla/cs-fundamentals.git","svn_url":"https://github.com/lacuchilla/cs-fundamentals","homepage":null,"size":24,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"sudocrystal:master","ref":"master","sha":"32d936d7c66dc5ddf49a8bba99faab6765ccb454","user":{"login":"sudocrystal","id":7967247,"avatar_url":"https://avatars.githubusercontent.com/u/7967247?v=3","gravatar_id":"","url":"https://api.github.com/users/sudocrystal","html_url":"https://github.com/sudocrystal","followers_url":"https://api.github.com/users/sudocrystal/followers","following_url":"https://api.github.com/users/sudocrystal/following{/other_user}","gists_url":"https://api.github.com/users/sudocrystal/gists{/gist_id}","starred_url":"https://api.github.com/users/sudocrystal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudocrystal/subscriptions","organizations_url":"https://api.github.com/users/sudocrystal/orgs","repos_url":"https://api.github.com/users/sudocrystal/repos","events_url":"https://api.github.com/users/sudocrystal/events{/privacy}","received_events_url":"https://api.github.com/users/sudocrystal/received_events","type":"User","site_admin":false},"repo":{"id":41561869,"name":"cs-fundamentals","full_name":"sudocrystal/cs-fundamentals","owner":{"login":"sudocrystal","id":7967247,"avatar_url":"https://avatars.githubusercontent.com/u/7967247?v=3","gravatar_id":"","url":"https://api.github.com/users/sudocrystal","html_url":"https://github.com/sudocrystal","followers_url":"https://api.github.com/users/sudocrystal/followers","following_url":"https://api.github.com/users/sudocrystal/following{/other_user}","gists_url":"https://api.github.com/users/sudocrystal/gists{/gist_id}","starred_url":"https://api.github.com/users/sudocrystal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudocrystal/subscriptions","organizations_url":"https://api.github.com/users/sudocrystal/orgs","repos_url":"https://api.github.com/users/sudocrystal/repos","events_url":"https://api.github.com/users/sudocrystal/events{/privacy}","received_events_url":"https://api.github.com/users/sudocrystal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sudocrystal/cs-fundamentals","description":"CS Fundamentals Series","fork":false,"url":"https://api.github.com/repos/sudocrystal/cs-fundamentals","forks_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/forks","keys_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/teams","hooks_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/hooks","issue_events_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues/events{/number}","events_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/events","assignees_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/assignees{/user}","branches_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/branches{/branch}","tags_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/tags","blobs_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/git/refs{/sha}","trees_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/statuses/{sha}","languages_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/languages","stargazers_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/stargazers","contributors_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/contributors","subscribers_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/subscribers","subscription_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/subscription","commits_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/commits{/sha}","git_commits_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/git/commits{/sha}","comments_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/comments{/number}","issue_comment_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues/comments{/number}","contents_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/contents/{+path}","compare_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/merges","archive_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/downloads","issues_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues{/number}","pulls_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls{/number}","milestones_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/milestones{/number}","notifications_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/labels{/name}","releases_url":"https://api.github.com/repos/sudocrystal/cs-fundamentals/releases{/id}","created_at":"2015-08-28T18:07:34Z","updated_at":"2015-12-06T00:30:07Z","pushed_at":"2015-12-14T07:26:32Z","git_url":"git://github.com/sudocrystal/cs-fundamentals.git","ssh_url":"git@github.com:sudocrystal/cs-fundamentals.git","clone_url":"https://github.com/sudocrystal/cs-fundamentals.git","svn_url":"https://github.com/sudocrystal/cs-fundamentals","homepage":null,"size":119,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":7,"forks":29,"open_issues":7,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/26"},"html":{"href":"https://github.com/sudocrystal/cs-fundamentals/pull/26"},"issue":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues/26"},"comments":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/sudocrystal/cs-fundamentals/statuses/88379e4350605214467f41518a2a7389a8b5699e"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":24,"deletions":0,"changed_files":1}}