@ -1,3 +1,67 @@
/ * a l p h a n u m . j s ( C ) B r i a n H u i s m a n
* Based on the Alphanum Algorithm by David Koelle
* The Alphanum Algorithm is discussed at http : //www.DaveKoelle.com
*
* Distributed under same license as original
*
* Released under the MIT License - https : //opensource.org/licenses/MIT
*
* Permission is hereby granted , free of charge , to any person obtaining
* a copy of this software and associated documentation files ( the "Software" ) ,
* to deal in the Software without restriction , including without limitation
* the rights to use , copy , modify , merge , publish , distribute , sublicense ,
* and / or sell copies of the Software , and to permit persons to whom the
* Software is furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
* EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT .
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM ,
* DAMAGES OR OTHER LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR
* OTHERWISE , ARISING FROM , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE .
* /
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Alphanum sort ( ) function version - case insensitive
* - Slower , but easier to modify for arrays of objects which contain
* string properties
*
* /
function alphanumCase ( a , b ) {
function chunkify ( t ) {
var tz = new Array ( ) ;
var x = 0 , y = - 1 , n = 0 , i , j ;
while ( i = ( j = t . charAt ( x ++ ) ) . charCodeAt ( 0 ) ) {
var m = ( i == 46 || ( i >= 48 && i <= 57 ) ) ;
if ( m !== n ) {
tz [ ++ y ] = "" ;
n = m ;
}
tz [ y ] += j ;
}
return tz ;
}
var aa = chunkify ( a . filename . toLowerCase ( ) ) ;
var bb = chunkify ( b . filename . toLowerCase ( ) ) ;
for ( x = 0 ; aa [ x ] && bb [ x ] ; x ++ ) {
if ( aa [ x ] !== bb [ x ] ) {
var c = Number ( aa [ x ] ) , d = Number ( bb [ x ] ) ;
if ( c == aa [ x ] && d == bb [ x ] ) {
return c - d ;
} else return ( aa [ x ] > bb [ x ] ) ? 1 : - 1 ;
}
}
return aa . length - bb . length ;
}
// ===========================================================================
/ * *
* archive . js
*
@ -13,22 +77,6 @@
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 ( ) {
// ===========================================================================