找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 577|回復: 0

[排序]中文筆畫排序

[複製鏈接]

257

主題

38

回帖

1138

積分

管理員

積分
1138
發表於 2023-5-25 10:57:38 | 顯示全部樓層 |閱讀模式

Sort Chinese characters

Sorting in Javascript for Chinese Character. The Chinese Characters are sorted on the radical and number of strokes. This plug-in performs sorting for Chinese characters using the Javascript localeCompare function.

Please note that localeCompare is not implemented in the same way in all browsers, potentially leading to different results (particularly in IE).

Plug-in code

1
2
3
4
5
6
7
8
9
jQuery.extend( jQuery.fn.dataTableExt.oSort, {<font></font>
    "chinese-string-asc" function (s1, s2) {<font></font>
        return s1.localeCompare(s2);<font></font>
    },<font></font>
<font></font>
    "chinese-string-desc" function (s1, s2) {<font></font>
        return s2.localeCompare(s1);<font></font>
    }<font></font>
} );<font></font>

CDN

This plug-in is available on the DataTables CDN:

JS

Note that if you are using multiple plug-ins, it is beneficial in terms of performance to combine the plug-ins into a single file and host it on your own server, rather than making multiple requests to the DataTables CDN.

Version control

If you have any ideas for how this plug-in can be improved, or spot anything that is in error, it is available on GitHub and pull requests are very welcome!

Example

1
2
3
4
5
$('#example').dataTable( {<font></font>
     columnDefs: [<font></font>
       { type: 'chinese-string', targets: 0 }<font></font>
     ]<font></font>
  } );<font></font>


您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

Archiver|手機版|小黑屋|DoIT 科技論壇

GMT+8, 2025-6-16 04:38 , Processed in 0.016103 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表