From 4caa171b5d90451d6b3f0790b9085c9e0e16f23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Casanova=20Gonz=C3=A1lez?= Date: Mon, 7 Jul 2014 13:14:21 +0200 Subject: [PATCH] Plugin for ordering correctly whith special chars. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Special chars like á or é are placed always at the end. This plugin orders them like if there were no special char. --- sorting/special-chars.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sorting/special-chars.js diff --git a/sorting/special-chars.js b/sorting/special-chars.js new file mode 100644 index 0000000..b31007f --- /dev/null +++ b/sorting/special-chars.js @@ -0,0 +1,17 @@ +jQuery.extend( jQuery.fn.dataTableExt.oSort, { + "special-chars-pre": function ( a ) { + return a.toLowerCase() + .replace( /\n/g, ' ' ) + .replace( /\u00e1/g, 'a' ) + .replace( /\u00e9/g, 'e' ) + .replace( /\u00ed/g, 'i' ) + .replace( /\u00f3/g, 'o' ) + .replace( /\u00fa/g, 'u' ) + .replace( /\u00ea/g, 'e' ) + .replace( /\u00ee/g, 'i' ) + .replace( /\u00f4/g, 'o' ) + .replace( /\u00e8/g, 'e' ) + .replace( /\u00ef/g, 'i' ) + .replace( /\u00fc/g, 'u' ); + } +} );