Last active
February 14, 2020 12:32
-
-
Save defektive/7a546d70452fa7771b219961f11e092b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s.sort((a,b) => { | |
a = a.replace(/^[a-z]+:\/\//, '') | |
b = b.replace(/^[a-z]+:\/\//, '') | |
a = a.split("/")[0]; | |
b = b.split("/")[0]; | |
if (a.indexOf('.') === -1) return 1 | |
if (b.indexOf('.') === -1) return -1 | |
let aa = a.split("."), | |
bb = b.split("."), | |
m = Math.min(aa.length, bb.length), | |
i = 0; | |
while (m--) { | |
i++ | |
let ap = aa[aa.length - i], | |
bp = bb[bb.length - i]; | |
if (ap == bp) continue | |
if ([ap, bp].sort()[0] != ap) return 1 | |
return -1 | |
} | |
return 0; | |
}).join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment