Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hungarian string sort #396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions sorting/hungarian-string.js
Original file line number Diff line number Diff line change
@@ -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", "ő": "od",
"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));
}
});