From e6bcec17664750965abb798c2408c50b3e49ebb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karmacsi=20G=C3=A1bor?= Date: Thu, 27 Sep 2018 21:45:05 +0200 Subject: [PATCH 1/2] Hungarian string sort --- sorting/hungarian-string.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 sorting/hungarian-string.js diff --git a/sorting/hungarian-string.js b/sorting/hungarian-string.js new file mode 100644 index 00000000..9babc43f --- /dev/null +++ b/sorting/hungarian-string.js @@ -0,0 +1,37 @@ +/** + * This plug-in provides locale aware sorting for Hungarian. + * + * @name Hungarian + * @summary Sort locale aware sorting for Hungarian. + * @author Karmacsi Gábor (Carmachy) + * + * @example + * $('#example').dataTable( { + * columnDefs: [ + * { type: 'hungarian', targets: 0 } + * ] + * } ); + */ + +$.extend( $.fn.dataTableExt.oSort, { + "hungarian-pre": function ( a ) { + var special_letters = { + "A": "Aa", "a": "aa", "Á": "Ab", "á": "ab", + "E": "Ea", "e": "ea", "É": "eb", "é": "eb", + "I": "Ia", "i": "ia", "Í": "Ib", "í": "ib", + "O": "Oa", "o": "oa", "Ó": "Ob", "ó": "ob", "Ö": "oc", "ö": "oc", "Ő": "od", "ő": "oc", + "U": "Ua", "u": "ua", "Ú": "Ub", "ú": "ub", "Ü": "Uc", "ü": "uc", "Ű": "ud", "ű": "ud" + }; + for (var val in special_letters) + a = a.split(val).join(special_letters[val]).toLowerCase(); + return a; + }, + + "hungarian-asc": function ( a, b ) { + return ((a < b) ? -1 : ((a > b) ? 1 : 0)); + }, + + "hungarian-desc": function ( a, b ) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); + } +}); \ No newline at end of file From 1fdf4a0d3ef28f1a23ae88fcc62cee1a94bf4625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karmacsi=20G=C3=A1bor?= Date: Thu, 27 Sep 2018 21:53:05 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Fixed:=20"=C5=91":=20"od"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sorting/hungarian-string.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorting/hungarian-string.js b/sorting/hungarian-string.js index 9babc43f..9402d40a 100644 --- a/sorting/hungarian-string.js +++ b/sorting/hungarian-string.js @@ -19,7 +19,7 @@ $.extend( $.fn.dataTableExt.oSort, { "A": "Aa", "a": "aa", "Á": "Ab", "á": "ab", "E": "Ea", "e": "ea", "É": "eb", "é": "eb", "I": "Ia", "i": "ia", "Í": "Ib", "í": "ib", - "O": "Oa", "o": "oa", "Ó": "Ob", "ó": "ob", "Ö": "oc", "ö": "oc", "Ő": "od", "ő": "oc", + "O": "Oa", "o": "oa", "Ó": "Ob", "ó": "ob", "Ö": "oc", "ö": "oc", "Ő": "od", "ő": "od", "U": "Ua", "u": "ua", "Ú": "Ub", "ú": "ub", "Ü": "Uc", "ü": "uc", "Ű": "ud", "ű": "ud" }; for (var val in special_letters)