mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
cache natural sort regex
This commit is contained in:
parent
5d91d5e81a
commit
7269aadc74
@ -1155,6 +1155,8 @@
|
||||
// regex used in natural sort
|
||||
ts.regex = {
|
||||
chunk : /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, // chunk/tokenize numbers & letters
|
||||
schunk: /^\\0/, // start chunk
|
||||
echunk: /\\0$/, // end chunk
|
||||
hex: /^0x[0-9a-f]+$/i // hex
|
||||
};
|
||||
|
||||
@ -1171,8 +1173,8 @@
|
||||
if ( xD > yD ) { return 1; }
|
||||
}
|
||||
// chunk/tokenize
|
||||
xN = a.replace(r.chunk, '\\0$1\\0').replace(/\\0$/, '').replace(/^\\0/, '').split('\\0');
|
||||
yN = b.replace(r.chunk, '\\0$1\\0').replace(/\\0$/, '').replace(/^\\0/, '').split('\\0');
|
||||
xN = a.replace(r.chunk, '\\0$1\\0').replace(r.echunk, '').replace(r.schunk, '').split('\\0');
|
||||
yN = b.replace(r.chunk, '\\0$1\\0').replace(r.echunk, '').replace(r.schunk, '').split('\\0');
|
||||
mx = Math.max(xN.length, yN.length);
|
||||
// natural sorting through split numeric strings and default strings
|
||||
for (i = 0; i < mx; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user