js-cfb/bits/33_sort.js

10 lines
321 B
JavaScript

/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
for(var i = 0, c = 0, Z = Math.min(L.length, R.length); i < Z; ++i) {
if((c = L[i].length - R[i].length)) return c;
if(L[i] != R[i]) return L[i] < R[i] ? -1 : 1;
}
return L.length - R.length;
}