{"action":"created","comment":{"url":"https://api.github.com/repos/samvera/questioning_authority/pulls/comments/239888003","pull_request_review_id":182793749,"id":239888003,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzOTg4ODAwMw==","diff_hunk":"@@ -0,0 +1,265 @@\n+# Provide service for for sorting an array of hash based on the values at a specified key in the hash.\n+module Qa\n+  module LinkedData\n+    class DeepSortService\n+      attr_reader :a_element, :b_element, :the_array, :sort_key, :preferred_language\n+      private :a_element, :b_element, :the_array, :sort_key, :preferred_language\n+\n+      # @params [Array<Hash<Symbol,Array<RDF::Literal>>>] the array of hashes to sort\n+      # @params [sort_key] the key in the hash on whose value the array will be sorted\n+      # @returns instance of this class\n+      # @example the_array parameter\n+      #   [\n+      #     {:uri=>[#<RDF::URI:0x3fcff54a829c URI:http://id.loc.gov/authorities/names/n2010043281>],\n+      #      :id=>[#<RDF::Literal:0x3fcff4a367b4(\"n 2010043281\")>],\n+      #      :label=>[#<RDF::Literal:0x3fcff54a9a98(\"Valli, Sabrina\"@en)>],\n+      #      :altlabel=>[],\n+      #      :sort=>[#<RDF::Literal:0x3fcff54b4c18(\"2\")>]}\n+      #     {:uri=>[#<RDF::URI:0x3fcff54a829c URI:http://id.loc.gov/authorities/names/n201002344>],\n+      #      :id=>[#<RDF::Literal:0x3fcff4a367b4(\"n 201002344\")>],\n+      #      :label=>[#<RDF::Literal:0x3fcff54a9a98(\"Cornell, Joseph\"@en)>],\n+      #      :altlabel=>[],\n+      #      :sort=>[#<RDF::Literal:0x3fcff54b4c18(\"1\")>]}\n+      #   ]\n+      def initialize(the_array, sort_key, preferred_language = :en)\n+        @the_array = the_array\n+        @sort_key = sort_key\n+        @preferred_language = preferred_language\n+      end\n+\n+      # Sort an array of hash on the specified sort key.  The value in the hash at sort key is expected to be an array\n+      # with one or more values that are RDF::Literals that translate to a number (e.g. 2), a string number (e.g. \"3\"),\n+      # a string (e.g. \"hello\"), or a language qualified string (e.g. \"hello\"@en).\n+      # The sort occurs in the following precedence.\n+      # * preference for numeric sort (if only one value each and both are integers or a string that can be converted to an integer)\n+      # * single value sort (if only one value each and at least one is not an integer)\n+      # * multiple values sort (if either has multiple values)\n+      # @returns the sorted array\n+      def sort\n+        return @sorted_array if @sorted_array.present?\n+        presort_sortkey_values\n+        @sorted_array = @the_array.sort do |a, b|\n+          setup_comparison(a, b, sort_key)\n+          next numeric_comparator if both_integers?\n+          next single_value_comparator if both_single?\n+          multiple_value_comparator\n+        end\n+      end\n+\n+      private\n+\n+        def presort_sortkey_values\n+          the_array.map! do |element|\n+            element[sort_key] = Qa::LinkedData::LanguageSortService.new(element[sort_key], preferred_language).sort","path":"app/services/qa/linked_data/deep_sort_service.rb","position":53,"original_position":53,"commit_id":"3e64574f0e701a27bd5af48c348fab4149cd3a3a","original_commit_id":"3e64574f0e701a27bd5af48c348fab4149cd3a3a","user":{"login":"cam156","id":1599081,"node_id":"MDQ6VXNlcjE1OTkwODE=","avatar_url":"https://avatars2.githubusercontent.com/u/1599081?v=4","gravatar_id":"","url":"https://api.github.com/users/cam156","html_url":"https://github.com/cam156","followers_url":"https://api.github.com/users/cam156/followers","following_url":"https://api.github.com/users/cam156/following{/other_user}","gists_url":"https://api.github.com/users/cam156/gists{/gist_id}","starred_url":"https://api.github.com/users/cam156/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cam156/subscriptions","organizations_url":"https://api.github.com/users/cam156/orgs","repos_url":"https://api.github.com/users/cam156/repos","events_url":"https://api.github.com/users/cam156/events{/privacy}","received_events_url":"https://api.github.com/users/cam156/received_events","type":"User","site_admin":false},"body":"If the array was mapped to DeepSortElements you could take advantage of sorted_literals in that class here?","created_at":"2018-12-07T17:37:21Z","updated_at":"2018-12-07T17:40:34Z","html_url":"https://github.com/samvera/questioning_authority/pull/189#discussion_r239888003","pull_request_url":"https://api.github.com/repos/samvera/questioning_authority/pulls/189","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/samvera/questioning_authority/pulls/comments/239888003"},"html":{"href":"https://github.com/samvera/questioning_authority/pull/189#discussion_r239888003"},"pull_request":{"href":"https://api.github.com/repos/samvera/questioning_authority/pulls/189"}}},"pull_request":{"url":"https://api.github.com/repos/samvera/questioning_authority/pulls/189","id":236705712,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM2NzA1NzEy","html_url":"https://github.com/samvera/questioning_authority/pull/189","diff_url":"https://github.com/samvera/questioning_authority/pull/189.diff","patch_url":"https://github.com/samvera/questioning_authority/pull/189.patch","issue_url":"https://api.github.com/repos/samvera/questioning_authority/issues/189","number":189,"state":"open","locked":false,"title":"Refactor sort process into a service","user":{"login":"elrayle","id":6855473,"node_id":"MDQ6VXNlcjY4NTU0NzM=","avatar_url":"https://avatars0.githubusercontent.com/u/6855473?v=4","gravatar_id":"","url":"https://api.github.com/users/elrayle","html_url":"https://github.com/elrayle","followers_url":"https://api.github.com/users/elrayle/followers","following_url":"https://api.github.com/users/elrayle/following{/other_user}","gists_url":"https://api.github.com/users/elrayle/gists{/gist_id}","starred_url":"https://api.github.com/users/elrayle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elrayle/subscriptions","organizations_url":"https://api.github.com/users/elrayle/orgs","repos_url":"https://api.github.com/users/elrayle/repos","events_url":"https://api.github.com/users/elrayle/events{/privacy}","received_events_url":"https://api.github.com/users/elrayle/received_events","type":"User","site_admin":false},"body":"The sort process is complex.  The tests for deep_sort_service lays out the various potential sorting scenarios.  Precedence on sort...\r\n\r\n* numeric sort, if both are integers\r\n* simple alpha sort of one term, if both are single value\r\n* same language list comparison, if all terms in a list are the same language or no language\r\n* preferred language comparison only, if both lists have the at least one term in the preferred language\r\n* calculate the comparator value for every language individually and sum to get a relative comparison of two multi-language lists (Best I could come up with.  I am open to suggestions.  In most cases, if not all, one of the earlier comparators will be selected.  This is the junk drawer of multi-lingual sorting.)","created_at":"2018-12-06T23:20:09Z","updated_at":"2018-12-07T17:40:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6da88e7a23e038094ecd036fb1762691883f57a0","assignee":{"login":"elrayle","id":6855473,"node_id":"MDQ6VXNlcjY4NTU0NzM=","avatar_url":"https://avatars0.githubusercontent.com/u/6855473?v=4","gravatar_id":"","url":"https://api.github.com/users/elrayle","html_url":"https://github.com/elrayle","followers_url":"https://api.github.com/users/elrayle/followers","following_url":"https://api.github.com/users/elrayle/following{/other_user}","gists_url":"https://api.github.com/users/elrayle/gists{/gist_id}","starred_url":"https://api.github.com/users/elrayle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elrayle/subscriptions","organizations_url":"https://api.github.com/users/elrayle/orgs","repos_url":"https://api.github.com/users/elrayle/repos","events_url":"https://api.github.com/users/elrayle/events{/privacy}","received_events_url":"https://api.github.com/users/elrayle/received_events","type":"User","site_admin":false},"assignees":[{"login":"elrayle","id":6855473,"node_id":"MDQ6VXNlcjY4NTU0NzM=","avatar_url":"https://avatars0.githubusercontent.com/u/6855473?v=4","gravatar_id":"","url":"https://api.github.com/users/elrayle","html_url":"https://github.com/elrayle","followers_url":"https://api.github.com/users/elrayle/followers","following_url":"https://api.github.com/users/elrayle/following{/other_user}","gists_url":"https://api.github.com/users/elrayle/gists{/gist_id}","starred_url":"https://api.github.com/users/elrayle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elrayle/subscriptions","organizations_url":"https://api.github.com/users/elrayle/orgs","repos_url":"https://api.github.com/users/elrayle/repos","events_url":"https://api.github.com/users/elrayle/events{/privacy}","received_events_url":"https://api.github.com/users/elrayle/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/samvera/questioning_authority/pulls/189/commits","review_comments_url":"https://api.github.com/repos/samvera/questioning_authority/pulls/189/comments","review_comment_url":"https://api.github.com/repos/samvera/questioning_authority/pulls/comments{/number}","comments_url":"https://api.github.com/repos/samvera/questioning_authority/issues/189/comments","statuses_url":"https://api.github.com/repos/samvera/questioning_authority/statuses/3e64574f0e701a27bd5af48c348fab4149cd3a3a","head":{"label":"samvera:ld_refactor_sort","ref":"ld_refactor_sort","sha":"3e64574f0e701a27bd5af48c348fab4149cd3a3a","user":{"login":"samvera","id":109426,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwOTQyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109426?v=4","gravatar_id":"","url":"https://api.github.com/users/samvera","html_url":"https://github.com/samvera","followers_url":"https://api.github.com/users/samvera/followers","following_url":"https://api.github.com/users/samvera/following{/other_user}","gists_url":"https://api.github.com/users/samvera/gists{/gist_id}","starred_url":"https://api.github.com/users/samvera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samvera/subscriptions","organizations_url":"https://api.github.com/users/samvera/orgs","repos_url":"https://api.github.com/users/samvera/repos","events_url":"https://api.github.com/users/samvera/events{/privacy}","received_events_url":"https://api.github.com/users/samvera/received_events","type":"Organization","site_admin":false},"repo":{"id":12877283,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg3NzI4Mw==","name":"questioning_authority","full_name":"samvera/questioning_authority","private":false,"owner":{"login":"samvera","id":109426,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwOTQyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109426?v=4","gravatar_id":"","url":"https://api.github.com/users/samvera","html_url":"https://github.com/samvera","followers_url":"https://api.github.com/users/samvera/followers","following_url":"https://api.github.com/users/samvera/following{/other_user}","gists_url":"https://api.github.com/users/samvera/gists{/gist_id}","starred_url":"https://api.github.com/users/samvera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samvera/subscriptions","organizations_url":"https://api.github.com/users/samvera/orgs","repos_url":"https://api.github.com/users/samvera/repos","events_url":"https://api.github.com/users/samvera/events{/privacy}","received_events_url":"https://api.github.com/users/samvera/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/samvera/questioning_authority","description":"Question your authorities","fork":false,"url":"https://api.github.com/repos/samvera/questioning_authority","forks_url":"https://api.github.com/repos/samvera/questioning_authority/forks","keys_url":"https://api.github.com/repos/samvera/questioning_authority/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samvera/questioning_authority/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samvera/questioning_authority/teams","hooks_url":"https://api.github.com/repos/samvera/questioning_authority/hooks","issue_events_url":"https://api.github.com/repos/samvera/questioning_authority/issues/events{/number}","events_url":"https://api.github.com/repos/samvera/questioning_authority/events","assignees_url":"https://api.github.com/repos/samvera/questioning_authority/assignees{/user}","branches_url":"https://api.github.com/repos/samvera/questioning_authority/branches{/branch}","tags_url":"https://api.github.com/repos/samvera/questioning_authority/tags","blobs_url":"https://api.github.com/repos/samvera/questioning_authority/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samvera/questioning_authority/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samvera/questioning_authority/git/refs{/sha}","trees_url":"https://api.github.com/repos/samvera/questioning_authority/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samvera/questioning_authority/statuses/{sha}","languages_url":"https://api.github.com/repos/samvera/questioning_authority/languages","stargazers_url":"https://api.github.com/repos/samvera/questioning_authority/stargazers","contributors_url":"https://api.github.com/repos/samvera/questioning_authority/contributors","subscribers_url":"https://api.github.com/repos/samvera/questioning_authority/subscribers","subscription_url":"https://api.github.com/repos/samvera/questioning_authority/subscription","commits_url":"https://api.github.com/repos/samvera/questioning_authority/commits{/sha}","git_commits_url":"https://api.github.com/repos/samvera/questioning_authority/git/commits{/sha}","comments_url":"https://api.github.com/repos/samvera/questioning_authority/comments{/number}","issue_comment_url":"https://api.github.com/repos/samvera/questioning_authority/issues/comments{/number}","contents_url":"https://api.github.com/repos/samvera/questioning_authority/contents/{+path}","compare_url":"https://api.github.com/repos/samvera/questioning_authority/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samvera/questioning_authority/merges","archive_url":"https://api.github.com/repos/samvera/questioning_authority/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samvera/questioning_authority/downloads","issues_url":"https://api.github.com/repos/samvera/questioning_authority/issues{/number}","pulls_url":"https://api.github.com/repos/samvera/questioning_authority/pulls{/number}","milestones_url":"https://api.github.com/repos/samvera/questioning_authority/milestones{/number}","notifications_url":"https://api.github.com/repos/samvera/questioning_authority/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samvera/questioning_authority/labels{/name}","releases_url":"https://api.github.com/repos/samvera/questioning_authority/releases{/id}","deployments_url":"https://api.github.com/repos/samvera/questioning_authority/deployments","created_at":"2013-09-16T19:59:48Z","updated_at":"2018-12-07T14:46:45Z","pushed_at":"2018-12-07T14:46:46Z","git_url":"git://github.com/samvera/questioning_authority.git","ssh_url":"git@github.com:samvera/questioning_authority.git","clone_url":"https://github.com/samvera/questioning_authority.git","svn_url":"https://github.com/samvera/questioning_authority","homepage":null,"size":3030,"stargazers_count":39,"watchers_count":39,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":21,"open_issues":19,"watchers":39,"default_branch":"master"}},"base":{"label":"samvera:master","ref":"master","sha":"e6e48f284044589829c8fa94419733253af54d18","user":{"login":"samvera","id":109426,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwOTQyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109426?v=4","gravatar_id":"","url":"https://api.github.com/users/samvera","html_url":"https://github.com/samvera","followers_url":"https://api.github.com/users/samvera/followers","following_url":"https://api.github.com/users/samvera/following{/other_user}","gists_url":"https://api.github.com/users/samvera/gists{/gist_id}","starred_url":"https://api.github.com/users/samvera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samvera/subscriptions","organizations_url":"https://api.github.com/users/samvera/orgs","repos_url":"https://api.github.com/users/samvera/repos","events_url":"https://api.github.com/users/samvera/events{/privacy}","received_events_url":"https://api.github.com/users/samvera/received_events","type":"Organization","site_admin":false},"repo":{"id":12877283,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg3NzI4Mw==","name":"questioning_authority","full_name":"samvera/questioning_authority","private":false,"owner":{"login":"samvera","id":109426,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwOTQyNg==","avatar_url":"https://avatars2.githubusercontent.com/u/109426?v=4","gravatar_id":"","url":"https://api.github.com/users/samvera","html_url":"https://github.com/samvera","followers_url":"https://api.github.com/users/samvera/followers","following_url":"https://api.github.com/users/samvera/following{/other_user}","gists_url":"https://api.github.com/users/samvera/gists{/gist_id}","starred_url":"https://api.github.com/users/samvera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samvera/subscriptions","organizations_url":"https://api.github.com/users/samvera/orgs","repos_url":"https://api.github.com/users/samvera/repos","events_url":"https://api.github.com/users/samvera/events{/privacy}","received_events_url":"https://api.github.com/users/samvera/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/samvera/questioning_authority","description":"Question your authorities","fork":false,"url":"https://api.github.com/repos/samvera/questioning_authority","forks_url":"https://api.github.com/repos/samvera/questioning_authority/forks","keys_url":"https://api.github.com/repos/samvera/questioning_authority/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samvera/questioning_authority/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samvera/questioning_authority/teams","hooks_url":"https://api.github.com/repos/samvera/questioning_authority/hooks","issue_events_url":"https://api.github.com/repos/samvera/questioning_authority/issues/events{/number}","events_url":"https://api.github.com/repos/samvera/questioning_authority/events","assignees_url":"https://api.github.com/repos/samvera/questioning_authority/assignees{/user}","branches_url":"https://api.github.com/repos/samvera/questioning_authority/branches{/branch}","tags_url":"https://api.github.com/repos/samvera/questioning_authority/tags","blobs_url":"https://api.github.com/repos/samvera/questioning_authority/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samvera/questioning_authority/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samvera/questioning_authority/git/refs{/sha}","trees_url":"https://api.github.com/repos/samvera/questioning_authority/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samvera/questioning_authority/statuses/{sha}","languages_url":"https://api.github.com/repos/samvera/questioning_authority/languages","stargazers_url":"https://api.github.com/repos/samvera/questioning_authority/stargazers","contributors_url":"https://api.github.com/repos/samvera/questioning_authority/contributors","subscribers_url":"https://api.github.com/repos/samvera/questioning_authority/subscribers","subscription_url":"https://api.github.com/repos/samvera/questioning_authority/subscription","commits_url":"https://api.github.com/repos/samvera/questioning_authority/commits{/sha}","git_commits_url":"https://api.github.com/repos/samvera/questioning_authority/git/commits{/sha}","comments_url":"https://api.github.com/repos/samvera/questioning_authority/comments{/number}","issue_comment_url":"https://api.github.com/repos/samvera/questioning_authority/issues/comments{/number}","contents_url":"https://api.github.com/repos/samvera/questioning_authority/contents/{+path}","compare_url":"https://api.github.com/repos/samvera/questioning_authority/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samvera/questioning_authority/merges","archive_url":"https://api.github.com/repos/samvera/questioning_authority/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samvera/questioning_authority/downloads","issues_url":"https://api.github.com/repos/samvera/questioning_authority/issues{/number}","pulls_url":"https://api.github.com/repos/samvera/questioning_authority/pulls{/number}","milestones_url":"https://api.github.com/repos/samvera/questioning_authority/milestones{/number}","notifications_url":"https://api.github.com/repos/samvera/questioning_authority/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samvera/questioning_authority/labels{/name}","releases_url":"https://api.github.com/repos/samvera/questioning_authority/releases{/id}","deployments_url":"https://api.github.com/repos/samvera/questioning_authority/deployments","created_at":"2013-09-16T19:59:48Z","updated_at":"2018-12-07T14:46:45Z","pushed_at":"2018-12-07T14:46:46Z","git_url":"git://github.com/samvera/questioning_authority.git","ssh_url":"git@github.com:samvera/questioning_authority.git","clone_url":"https://github.com/samvera/questioning_authority.git","svn_url":"https://github.com/samvera/questioning_authority","homepage":null,"size":3030,"stargazers_count":39,"watchers_count":39,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":21,"open_issues":19,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/samvera/questioning_authority/pulls/189"},"html":{"href":"https://github.com/samvera/questioning_authority/pull/189"},"issue":{"href":"https://api.github.com/repos/samvera/questioning_authority/issues/189"},"comments":{"href":"https://api.github.com/repos/samvera/questioning_authority/issues/189/comments"},"review_comments":{"href":"https://api.github.com/repos/samvera/questioning_authority/pulls/189/comments"},"review_comment":{"href":"https://api.github.com/repos/samvera/questioning_authority/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/samvera/questioning_authority/pulls/189/commits"},"statuses":{"href":"https://api.github.com/repos/samvera/questioning_authority/statuses/3e64574f0e701a27bd5af48c348fab4149cd3a3a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"cam156"}}