export function defaultSortMethod ( a , b ) { a = a === null || a === undefined ? - Infinity : a ; b = b === null || b === undefined ? - Infinity : b ; a = typeof a === 'string' ? a . toLowerCase ( ) : a ; b = typeof b === 'string' ? b . toLowerCase ( ) : b ; if ( a > b ) { return 1 ; } if ( a < b ) { return - 1 ; } return 0 ; } export function defaultStringArraySortMethod ( a , b ) { return defaultSortMethod ( a . join ( ) , b . join ( ) ) ; } export function defaultArraySortMethod < U extends number | string > ( a , b ) { let result = 0 ; const loopLength = Math . min ( a . length , b . length ) ; for ( let i = 0 ; i < loopLength ; i ++ ) { result = defaultSortMethod ( a [ i ] , b [ i ] ) ; if ( result !== 0 ) { break ; } } if ( result === 0 ) { if ( a . length < b . length ) { result = - 1 ; } else if ( a . length > b . length ) { result = 1 ; } } return result ; }