{"action":"created","issue":{"url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/601","labels_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/601/labels{/name}","comments_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/601/comments","events_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/601/events","html_url":"https://github.com/lorenzofox3/Smart-Table/issues/601","id":127822633,"number":601,"title":"sort data with CJK (Chinese Japanese Korean)?","user":{"login":"Tedko","id":6687437,"avatar_url":"https://avatars.githubusercontent.com/u/6687437?v=3","gravatar_id":"","url":"https://api.github.com/users/Tedko","html_url":"https://github.com/Tedko","followers_url":"https://api.github.com/users/Tedko/followers","following_url":"https://api.github.com/users/Tedko/following{/other_user}","gists_url":"https://api.github.com/users/Tedko/gists{/gist_id}","starred_url":"https://api.github.com/users/Tedko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tedko/subscriptions","organizations_url":"https://api.github.com/users/Tedko/orgs","repos_url":"https://api.github.com/users/Tedko/repos","events_url":"https://api.github.com/users/Tedko/events{/privacy}","received_events_url":"https://api.github.com/users/Tedko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-21T01:13:17Z","updated_at":"2016-01-21T02:04:52Z","closed_at":null,"body":"Hey, \r\nI am trying to sort data with `st-sort` and seems like its not working with CJK (or working poorly)\r\n\r\nmy code:\r\n\r\n```html\r\n<table st-table=\"display_worker_list\" st-safe-src=\"worker_data.worker_list\" class=\"table table-striped\" >\r\n\t<thead>\r\n\t<tr>\r\n\t\t<th st-sort=\"sortGetter.logname\">用户名</th>\r\n\t\t<th st-sort=\"sortGetter.realname\">姓名</th>\r\n\t\t<th st-sort=\"sortGetter.task_submitted\">完成任务</th>\r\n\t\t<th st-sort=\"sortGetter.total_time_used\">总用时</th>\r\n\t\t<th st-sort=\"\">总盈利</th>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<th colspan=\"6\"><input st-search=\"\" class=\"form-control\" placeholder=\"搜索 ...\" type=\"text\"/></th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>\r\n\t<tr st-select-row=\"worker\" st-select-mode=\"single\" ng-repeat=\"worker in display_worker_list\">\r\n\r\n\t\t<td>{{worker.logname}}</td>\r\n\t\t<td>{{worker.realname}}</td>\r\n\t\t<td>{{worker.stat[data.taskSelect].task_submitted}}</td>\r\n\t\t<td>{{(worker.stat[data.taskSelect][\"total_time_used\"]).toFixed(5)}}</td>\r\n\t\t<td>{{}}</td>\r\n\t\t<td>\r\n\t\t\t<button type=\"button\" ng-click=\"removeItem(worker)\" class=\"btn btn-sm btn-danger\">\r\n\t\t\t\t<i class=\"glyphicon glyphicon-remove-circle\">\r\n\t\t\t\t</i>\r\n\t\t\t</button>\r\n\t\t</td>\r\n\t</tr>\r\n\t</tbody>\r\n\t<tfoot>\r\n\t<tr>\r\n\t\t<td colspan=\"6\" class=\"text-center\">\r\n\t\t\t<div st-pagination=\"\" st-items-by-page=\"15\"></div>\r\n\t\t</td>\r\n\t</tr>\r\n\t</tfoot>\r\n</table>\r\n```\r\nand js:\r\n\r\n```js\r\n         var sortGetter = {\r\n             logname: function (value) {\r\n                 return value.logname;\r\n             },\r\n             realname: function (value) {\r\n                 return value.realname;\r\n             },\r\n             task_submitted: function (value) {\r\n                return value.task_submitted;\r\n            }\r\n         };\r\n```\r\n\r\nHere, logname is in ASCII, so it works fine \r\n\r\n![2016-01-20 4 59 59](https://cloud.githubusercontent.com/assets/6687437/12468315/46760adc-bf97-11e5-9ca1-495bc4898823.png)\r\n\r\nhowever, the realname filed contains cjk, and  it works poorly:\r\n\r\n![2016-01-20 5 01 40](https://cloud.githubusercontent.com/assets/6687437/12468377/daebbe46-bf97-11e5-9db6-f07d028b5008.png)\r\n\r\nSeems like it is sorted by unicode? Did you implement your sort func in `.directive('stSort', ['stConfig', '$parse', '$timeout', function (stConfig, $parse, $timeout)`?\r\n\r\nI suggest that for cjk,\r\nChinese: sort by pinyin, such as 安（an）should before 宝（bao）, and all ascii go first.\r\nJapanes: by [五十音図](https://en.wikipedia.org/wiki/Goj%C5%ABon) all ascii go first and then あいうえお順\r\nKorean: similar above. by [Hangul](https://en.wikipedia.org/wiki/Hangul_consonant_and_vowel_tables) \r\n\r\nIf I have enough time I could create a pr for Chinese first. Please double check this issue.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/comments/173427621","html_url":"https://github.com/lorenzofox3/Smart-Table/issues/601#issuecomment-173427621","issue_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/601","id":173427621,"user":{"login":"timonwong","id":1398228,"avatar_url":"https://avatars.githubusercontent.com/u/1398228?v=3","gravatar_id":"","url":"https://api.github.com/users/timonwong","html_url":"https://github.com/timonwong","followers_url":"https://api.github.com/users/timonwong/followers","following_url":"https://api.github.com/users/timonwong/following{/other_user}","gists_url":"https://api.github.com/users/timonwong/gists{/gist_id}","starred_url":"https://api.github.com/users/timonwong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timonwong/subscriptions","organizations_url":"https://api.github.com/users/timonwong/orgs","repos_url":"https://api.github.com/users/timonwong/repos","events_url":"https://api.github.com/users/timonwong/events{/privacy}","received_events_url":"https://api.github.com/users/timonwong/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T02:04:52Z","updated_at":"2016-01-21T02:04:52Z","body":"The sort is not related to SmartTable, actually it's a internalization problem.\r\n\r\nIn backend programming language, you can use ICU's collator to do that, and sorting in the backend will give you better compatibility, because:\r\nThough we have [ECMA-402](http://www.ecma-international.org/ecma-402/1.0/), but with very limited browser support (IE 11+): http://caniuse.com/#feat=internationalization\r\n\r\nIn your example, you can change your comparator:\r\n```\r\nvar collator = new Intl.Collator(\"zh-CN\");\r\nvar standardComparator = collator.compare;\r\n```\r\n\r\nThe code above is a very simple demonstration, though, in real world example, it may be more complex. "}}