Sorting for comics
Audiobook support
This commit is contained in:
@ -13,6 +13,22 @@
|
||||
var bitjs = bitjs || {};
|
||||
bitjs.archive = bitjs.archive || {};
|
||||
|
||||
function naturalCompare(a, b) {
|
||||
var ax = [], bx = [];
|
||||
|
||||
a.filename.toLowerCase().replace(/(\d+)|(\D+)/g, function(_, $1, $2) { ax.push([$1 || Infinity, $2 || ""]) });
|
||||
b.filename.toLowerCase().replace(/(\d+)|(\D+)/g, function(_, $1, $2) { bx.push([$1 || Infinity, $2 || ""]) });
|
||||
|
||||
while(ax.length && bx.length) {
|
||||
var an = ax.shift();
|
||||
var bn = bx.shift();
|
||||
var nn = (an[0] - bn[0]) || an[1].localeCompare(bn[1]);
|
||||
if(nn) return nn;
|
||||
}
|
||||
|
||||
return ax.length - bx.length;
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
||||
// ===========================================================================
|
||||
|
Reference in New Issue
Block a user