{"action":"opened","number":118,"pull_request":{"url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/118","id":51943975,"html_url":"https://github.com/pivotal-energy-solutions/django-datatable-view/pull/118","diff_url":"https://github.com/pivotal-energy-solutions/django-datatable-view/pull/118.diff","patch_url":"https://github.com/pivotal-energy-solutions/django-datatable-view/pull/118.patch","issue_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues/118","number":118,"state":"open","locked":false,"title":"Fix virtual sort when comparing various-length values","user":{"login":"Zopieux","id":81353,"avatar_url":"https://avatars.githubusercontent.com/u/81353?v=3","gravatar_id":"","url":"https://api.github.com/users/Zopieux","html_url":"https://github.com/Zopieux","followers_url":"https://api.github.com/users/Zopieux/followers","following_url":"https://api.github.com/users/Zopieux/following{/other_user}","gists_url":"https://api.github.com/users/Zopieux/gists{/gist_id}","starred_url":"https://api.github.com/users/Zopieux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zopieux/subscriptions","organizations_url":"https://api.github.com/users/Zopieux/orgs","repos_url":"https://api.github.com/users/Zopieux/repos","events_url":"https://api.github.com/users/Zopieux/events{/privacy}","received_events_url":"https://api.github.com/users/Zopieux/received_events","type":"User","site_admin":false},"body":"### Steps to reproduce\r\n\r\n1. have a `Datatable` with\r\n   * a single-source column eg. `foo = TextColumn(\"foo\", sources=['foo'])`\r\n   * a dual-source column eg. `bar = TextColumn(\"bar\", sources=['bar', 'baz'])`\r\n1. in the corresponding `DatatableView`, sort by Foo then **further sort** (shift+click) by Bar\r\n\r\n### The trackback\r\n```python-traceback\r\n  File \"datatableview/datatables.py\", line 443, in populate_records\r\n    objects = self.sort(objects)\r\n  File \"datatableview/datatables.py\", line 521, in sort\r\n    object_list.sort(key=lambda o: column.value(o)[0], reverse=reverse)\r\nTypeError: unorderable types: list() < str()\r\n```\r\nIndeed, for *foo*, `column.value(o)` is `(\"foo-value\", \"Foo value\")`; whereas for *bar*, `column.value(o)` is `([\"bar-value\", \"baz-value\"], \"Bar Baz Value\")` hence Python tries to compare the string `\"foo-value\"` with the list `[\"bar-value\", \"baz-value\"]`.\r\n\r\n### The fix\r\nI recursively flatten the value so that it always return a literal we can compare to, instead of a list that can be nested. I am not sure this is the best approach but at least it works (debugged & tested in my project). Please tell me if I missed something.","created_at":"2015-11-26T20:23:58Z","updated_at":"2015-11-26T20:23:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/118/commits","review_comments_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/118/comments","review_comment_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues/118/comments","statuses_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/statuses/344fae031be95575f54cca0a0a6a53fa573f78bb","head":{"label":"Zopieux:patch-2","ref":"patch-2","sha":"344fae031be95575f54cca0a0a6a53fa573f78bb","user":{"login":"Zopieux","id":81353,"avatar_url":"https://avatars.githubusercontent.com/u/81353?v=3","gravatar_id":"","url":"https://api.github.com/users/Zopieux","html_url":"https://github.com/Zopieux","followers_url":"https://api.github.com/users/Zopieux/followers","following_url":"https://api.github.com/users/Zopieux/following{/other_user}","gists_url":"https://api.github.com/users/Zopieux/gists{/gist_id}","starred_url":"https://api.github.com/users/Zopieux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zopieux/subscriptions","organizations_url":"https://api.github.com/users/Zopieux/orgs","repos_url":"https://api.github.com/users/Zopieux/repos","events_url":"https://api.github.com/users/Zopieux/events{/privacy}","received_events_url":"https://api.github.com/users/Zopieux/received_events","type":"User","site_admin":false},"repo":{"id":46941904,"name":"django-datatable-view","full_name":"Zopieux/django-datatable-view","owner":{"login":"Zopieux","id":81353,"avatar_url":"https://avatars.githubusercontent.com/u/81353?v=3","gravatar_id":"","url":"https://api.github.com/users/Zopieux","html_url":"https://github.com/Zopieux","followers_url":"https://api.github.com/users/Zopieux/followers","following_url":"https://api.github.com/users/Zopieux/following{/other_user}","gists_url":"https://api.github.com/users/Zopieux/gists{/gist_id}","starred_url":"https://api.github.com/users/Zopieux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zopieux/subscriptions","organizations_url":"https://api.github.com/users/Zopieux/orgs","repos_url":"https://api.github.com/users/Zopieux/repos","events_url":"https://api.github.com/users/Zopieux/events{/privacy}","received_events_url":"https://api.github.com/users/Zopieux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Zopieux/django-datatable-view","description":"Yet another datatables implementation for Django","fork":true,"url":"https://api.github.com/repos/Zopieux/django-datatable-view","forks_url":"https://api.github.com/repos/Zopieux/django-datatable-view/forks","keys_url":"https://api.github.com/repos/Zopieux/django-datatable-view/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zopieux/django-datatable-view/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zopieux/django-datatable-view/teams","hooks_url":"https://api.github.com/repos/Zopieux/django-datatable-view/hooks","issue_events_url":"https://api.github.com/repos/Zopieux/django-datatable-view/issues/events{/number}","events_url":"https://api.github.com/repos/Zopieux/django-datatable-view/events","assignees_url":"https://api.github.com/repos/Zopieux/django-datatable-view/assignees{/user}","branches_url":"https://api.github.com/repos/Zopieux/django-datatable-view/branches{/branch}","tags_url":"https://api.github.com/repos/Zopieux/django-datatable-view/tags","blobs_url":"https://api.github.com/repos/Zopieux/django-datatable-view/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zopieux/django-datatable-view/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zopieux/django-datatable-view/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zopieux/django-datatable-view/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zopieux/django-datatable-view/statuses/{sha}","languages_url":"https://api.github.com/repos/Zopieux/django-datatable-view/languages","stargazers_url":"https://api.github.com/repos/Zopieux/django-datatable-view/stargazers","contributors_url":"https://api.github.com/repos/Zopieux/django-datatable-view/contributors","subscribers_url":"https://api.github.com/repos/Zopieux/django-datatable-view/subscribers","subscription_url":"https://api.github.com/repos/Zopieux/django-datatable-view/subscription","commits_url":"https://api.github.com/repos/Zopieux/django-datatable-view/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zopieux/django-datatable-view/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zopieux/django-datatable-view/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zopieux/django-datatable-view/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zopieux/django-datatable-view/contents/{+path}","compare_url":"https://api.github.com/repos/Zopieux/django-datatable-view/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zopieux/django-datatable-view/merges","archive_url":"https://api.github.com/repos/Zopieux/django-datatable-view/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zopieux/django-datatable-view/downloads","issues_url":"https://api.github.com/repos/Zopieux/django-datatable-view/issues{/number}","pulls_url":"https://api.github.com/repos/Zopieux/django-datatable-view/pulls{/number}","milestones_url":"https://api.github.com/repos/Zopieux/django-datatable-view/milestones{/number}","notifications_url":"https://api.github.com/repos/Zopieux/django-datatable-view/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zopieux/django-datatable-view/labels{/name}","releases_url":"https://api.github.com/repos/Zopieux/django-datatable-view/releases{/id}","created_at":"2015-11-26T18:33:49Z","updated_at":"2015-11-26T18:33:50Z","pushed_at":"2015-11-26T20:19:50Z","git_url":"git://github.com/Zopieux/django-datatable-view.git","ssh_url":"git@github.com:Zopieux/django-datatable-view.git","clone_url":"https://github.com/Zopieux/django-datatable-view.git","svn_url":"https://github.com/Zopieux/django-datatable-view","homepage":null,"size":885,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"pivotal-energy-solutions:master","ref":"master","sha":"b10292c9be43aae26675d64e4e51bde01b9155cf","user":{"login":"pivotal-energy-solutions","id":2971734,"avatar_url":"https://avatars.githubusercontent.com/u/2971734?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotal-energy-solutions","html_url":"https://github.com/pivotal-energy-solutions","followers_url":"https://api.github.com/users/pivotal-energy-solutions/followers","following_url":"https://api.github.com/users/pivotal-energy-solutions/following{/other_user}","gists_url":"https://api.github.com/users/pivotal-energy-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotal-energy-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotal-energy-solutions/subscriptions","organizations_url":"https://api.github.com/users/pivotal-energy-solutions/orgs","repos_url":"https://api.github.com/users/pivotal-energy-solutions/repos","events_url":"https://api.github.com/users/pivotal-energy-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/pivotal-energy-solutions/received_events","type":"Organization","site_admin":false},"repo":{"id":6802244,"name":"django-datatable-view","full_name":"pivotal-energy-solutions/django-datatable-view","owner":{"login":"pivotal-energy-solutions","id":2971734,"avatar_url":"https://avatars.githubusercontent.com/u/2971734?v=3","gravatar_id":"","url":"https://api.github.com/users/pivotal-energy-solutions","html_url":"https://github.com/pivotal-energy-solutions","followers_url":"https://api.github.com/users/pivotal-energy-solutions/followers","following_url":"https://api.github.com/users/pivotal-energy-solutions/following{/other_user}","gists_url":"https://api.github.com/users/pivotal-energy-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/pivotal-energy-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pivotal-energy-solutions/subscriptions","organizations_url":"https://api.github.com/users/pivotal-energy-solutions/orgs","repos_url":"https://api.github.com/users/pivotal-energy-solutions/repos","events_url":"https://api.github.com/users/pivotal-energy-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/pivotal-energy-solutions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pivotal-energy-solutions/django-datatable-view","description":"Yet another datatables implementation for Django","fork":false,"url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view","forks_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/forks","keys_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/teams","hooks_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/hooks","issue_events_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues/events{/number}","events_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/events","assignees_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/assignees{/user}","branches_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/branches{/branch}","tags_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/tags","blobs_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/git/refs{/sha}","trees_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/statuses/{sha}","languages_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/languages","stargazers_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/stargazers","contributors_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/contributors","subscribers_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/subscribers","subscription_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/subscription","commits_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/commits{/sha}","git_commits_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/git/commits{/sha}","comments_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/comments{/number}","issue_comment_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues/comments{/number}","contents_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/contents/{+path}","compare_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/merges","archive_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/downloads","issues_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues{/number}","pulls_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls{/number}","milestones_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/milestones{/number}","notifications_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/labels{/name}","releases_url":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/releases{/id}","created_at":"2012-11-21T20:08:16Z","updated_at":"2015-11-26T17:41:51Z","pushed_at":"2015-11-26T18:35:58Z","git_url":"git://github.com/pivotal-energy-solutions/django-datatable-view.git","ssh_url":"git@github.com:pivotal-energy-solutions/django-datatable-view.git","clone_url":"https://github.com/pivotal-energy-solutions/django-datatable-view.git","svn_url":"https://github.com/pivotal-energy-solutions/django-datatable-view","homepage":null,"size":913,"stargazers_count":93,"watchers_count":93,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":23,"forks":47,"open_issues":23,"watchers":93,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/118"},"html":{"href":"https://github.com/pivotal-energy-solutions/django-datatable-view/pull/118"},"issue":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues/118"},"comments":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/issues/118/comments"},"review_comments":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/118/comments"},"review_comment":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/pulls/118/commits"},"statuses":{"href":"https://api.github.com/repos/pivotal-energy-solutions/django-datatable-view/statuses/344fae031be95575f54cca0a0a6a53fa573f78bb"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":8,"deletions":2,"changed_files":1}}