Fix: Natural sorting nono-standard methods were not reverse sorting

pull/567/head
Allan Jardine 1 year ago
parent 4b02618578
commit 94ba5b5873

@ -147,7 +147,7 @@ DataTable.ext.type.order['natural-desc'] = function (a, b) {
DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) {
return naturalSort(a, b, false);
};
DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) {
DataTable.ext.type.order['natural-nohtml-desc'] = function (a, b) {
return naturalSort(a, b, false) * -1;
};
DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
@ -155,7 +155,7 @@ DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
b = b.toString().toLowerCase();
return naturalSort(a, b, true);
};
DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
DataTable.ext.type.order['natural-ci-desc'] = function (a, b) {
a = a.toString().toLowerCase();
b = b.toString().toLowerCase();
return naturalSort(a, b, true) * -1;

@ -1,2 +1,2 @@
/*! © SpryMedia Ltd, Jim Palmer, Michael Buehler, Mike Grier, Clint Priest, Kyle Adams, guillermo - datatables.net/license */
!function(r){var n,a;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return r(e,window,document)}):"object"==typeof exports?(n=require("jquery"),a=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||n(e),a(e,t),r(t,0,e.document)}:(a(window,n),module.exports=r(n,window,window.document))):r(jQuery,window,document)}(function(e,t,r,n){"use strict";e=e.fn.dataTable;function a(e,t,r){var n=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?%?$|^0x[0-9a-f]+$|[0-9]+)/gi,a=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,i=/^0x[0-9a-f]+$/i,u=/^0/,c=/(<([^>]+)>)/gi,e=e.toString().replace(a,"")||"",t=t.toString().replace(a,"")||"",d=(r||(e=e.replace(c,""),t=t.replace(c,"")),e.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),f=t.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),a=parseInt(e.match(i),10)||1!==d.length&&e.match(o)&&Date.parse(e),r=parseInt(t.match(i),10)||a&&t.match(o)&&Date.parse(t)||null;if(r){if(a<r)return-1;if(r<a)return 1}for(var l=0,p=Math.max(d.length,f.length);l<p;l++){var s=!(d[l]||"").match(u)&&parseFloat(d[l])||d[l]||0,w=!(f[l]||"").match(u)&&parseFloat(f[l])||f[l]||0;if(isNaN(s)!==isNaN(w))return isNaN(s)?1:-1;if(typeof s!=typeof w&&(s+="",w+=""),s<w)return-1;if(w<s)return 1}return 0}return e.ext.type.order["natural-asc"]=function(e,t){return a(e,t,!0)},e.ext.type.order["natural-desc"]=function(e,t){return-1*a(e,t,!0)},e.ext.type.order["natural-nohtml-asc"]=function(e,t){return a(e,t,!1)},e.ext.type.order["natural-nohtml-asc"]=function(e,t){return-1*a(e,t,!1)},e.ext.type.order["natural-ci-asc"]=function(e,t){return a(e=e.toString().toLowerCase(),t=t.toString().toLowerCase(),!0)},e.ext.type.order["natural-ci-asc"]=function(e,t){return-1*a(e=e.toString().toLowerCase(),t=t.toString().toLowerCase(),!0)},e});
!function(r){var n,a;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return r(e,window,document)}):"object"==typeof exports?(n=require("jquery"),a=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||n(e),a(e,t),r(t,0,e.document)}:(a(window,n),module.exports=r(n,window,window.document))):r(jQuery,window,document)}(function(e,t,r,n){"use strict";e=e.fn.dataTable;function a(e,t,r){var n=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?%?$|^0x[0-9a-f]+$|[0-9]+)/gi,a=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,i=/^0x[0-9a-f]+$/i,u=/^0/,c=/(<([^>]+)>)/gi,e=e.toString().replace(a,"")||"",t=t.toString().replace(a,"")||"",d=(r||(e=e.replace(c,""),t=t.replace(c,"")),e.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),f=t.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),a=parseInt(e.match(i),10)||1!==d.length&&e.match(o)&&Date.parse(e),r=parseInt(t.match(i),10)||a&&t.match(o)&&Date.parse(t)||null;if(r){if(a<r)return-1;if(r<a)return 1}for(var l=0,p=Math.max(d.length,f.length);l<p;l++){var s=!(d[l]||"").match(u)&&parseFloat(d[l])||d[l]||0,w=!(f[l]||"").match(u)&&parseFloat(f[l])||f[l]||0;if(isNaN(s)!==isNaN(w))return isNaN(s)?1:-1;if(typeof s!=typeof w&&(s+="",w+=""),s<w)return-1;if(w<s)return 1}return 0}return e.ext.type.order["natural-asc"]=function(e,t){return a(e,t,!0)},e.ext.type.order["natural-desc"]=function(e,t){return-1*a(e,t,!0)},e.ext.type.order["natural-nohtml-asc"]=function(e,t){return a(e,t,!1)},e.ext.type.order["natural-nohtml-desc"]=function(e,t){return-1*a(e,t,!1)},e.ext.type.order["natural-ci-asc"]=function(e,t){return a(e=e.toString().toLowerCase(),t=t.toString().toLowerCase(),!0)},e.ext.type.order["natural-ci-desc"]=function(e,t){return-1*a(e=e.toString().toLowerCase(),t=t.toString().toLowerCase(),!0)},e});

@ -1,2 +1,2 @@
/*! © SpryMedia Ltd, Jim Palmer, Michael Buehler, Mike Grier, Clint Priest, Kyle Adams, guillermo - datatables.net/license */
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function naturalSort(t,a,r){var e=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?%?$|^0x[0-9a-f]+$|[0-9]+)/gi,n=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,u=/^0/,c=/(<([^>]+)>)/gi,t=t.toString().replace(n,"")||"",a=a.toString().replace(n,"")||"",i=(r||(t=t.replace(c,""),a=a.replace(c,"")),t.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),p=a.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),n=parseInt(t.match(l),10)||1!==i.length&&t.match(o)&&Date.parse(t),r=parseInt(a.match(l),10)||n&&a.match(o)&&Date.parse(a)||null;if(r){if(n<r)return-1;if(r<n)return 1}for(var f=0,s=Math.max(i.length,p.length);f<s;f++){var d=!(i[f]||"").match(u)&&parseFloat(i[f])||i[f]||0,m=!(p[f]||"").match(u)&&parseFloat(p[f])||p[f]||0;if(isNaN(d)!==isNaN(m))return isNaN(d)?1:-1;if(typeof d!=typeof m&&(d+="",m+=""),d<m)return-1;if(m<d)return 1}return 0}DataTable.ext.type.order["natural-asc"]=function(t,a){return naturalSort(t,a,!0)},DataTable.ext.type.order["natural-desc"]=function(t,a){return-1*naturalSort(t,a,!0)},DataTable.ext.type.order["natural-nohtml-asc"]=function(t,a){return naturalSort(t,a,!1)},DataTable.ext.type.order["natural-nohtml-asc"]=function(t,a){return-1*naturalSort(t,a,!1)},DataTable.ext.type.order["natural-ci-asc"]=function(t,a){return naturalSort(t=t.toString().toLowerCase(),a=a.toString().toLowerCase(),!0)},DataTable.ext.type.order["natural-ci-asc"]=function(t,a){return-1*naturalSort(t=t.toString().toLowerCase(),a=a.toString().toLowerCase(),!0)};export default DataTable;
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function naturalSort(t,a,r){var e=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?%?$|^0x[0-9a-f]+$|[0-9]+)/gi,n=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,u=/^0/,c=/(<([^>]+)>)/gi,t=t.toString().replace(n,"")||"",a=a.toString().replace(n,"")||"",i=(r||(t=t.replace(c,""),a=a.replace(c,"")),t.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")),p=a.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),n=parseInt(t.match(l),10)||1!==i.length&&t.match(o)&&Date.parse(t),r=parseInt(a.match(l),10)||n&&a.match(o)&&Date.parse(a)||null;if(r){if(n<r)return-1;if(r<n)return 1}for(var f=0,s=Math.max(i.length,p.length);f<s;f++){var d=!(i[f]||"").match(u)&&parseFloat(i[f])||i[f]||0,m=!(p[f]||"").match(u)&&parseFloat(p[f])||p[f]||0;if(isNaN(d)!==isNaN(m))return isNaN(d)?1:-1;if(typeof d!=typeof m&&(d+="",m+=""),d<m)return-1;if(m<d)return 1}return 0}DataTable.ext.type.order["natural-asc"]=function(t,a){return naturalSort(t,a,!0)},DataTable.ext.type.order["natural-desc"]=function(t,a){return-1*naturalSort(t,a,!0)},DataTable.ext.type.order["natural-nohtml-asc"]=function(t,a){return naturalSort(t,a,!1)},DataTable.ext.type.order["natural-nohtml-desc"]=function(t,a){return-1*naturalSort(t,a,!1)},DataTable.ext.type.order["natural-ci-asc"]=function(t,a){return naturalSort(t=t.toString().toLowerCase(),a=a.toString().toLowerCase(),!0)},DataTable.ext.type.order["natural-ci-desc"]=function(t,a){return-1*naturalSort(t=t.toString().toLowerCase(),a=a.toString().toLowerCase(),!0)};export default DataTable;

@ -107,7 +107,7 @@ DataTable.ext.type.order['natural-desc'] = function (a, b) {
DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) {
return naturalSort(a, b, false);
};
DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) {
DataTable.ext.type.order['natural-nohtml-desc'] = function (a, b) {
return naturalSort(a, b, false) * -1;
};
DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
@ -115,7 +115,7 @@ DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
b = b.toString().toLowerCase();
return naturalSort(a, b, true);
};
DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
DataTable.ext.type.order['natural-ci-desc'] = function (a, b) {
a = a.toString().toLowerCase();
b = b.toString().toLowerCase();
return naturalSort(a, b, true) * -1;

@ -132,7 +132,7 @@ DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) {
return naturalSort(a, b, false);
};
DataTable.ext.type.order['natural-nohtml-asc'] = function (a, b) {
DataTable.ext.type.order['natural-nohtml-desc'] = function (a, b) {
return naturalSort(a, b, false) * -1;
};
@ -143,7 +143,7 @@ DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
return naturalSort(a, b, true);
};
DataTable.ext.type.order['natural-ci-asc'] = function (a, b) {
DataTable.ext.type.order['natural-ci-desc'] = function (a, b) {
a = a.toString().toLowerCase();
b = b.toString().toLowerCase();

Loading…
Cancel
Save