Skip to content

Instantly share code, notes, and snippets.

@adoji92

adoji92/sort.js

Created Feb 14, 2018
Embed
What would you like to do?
function strComp(a, b) {
for (let i = 0; i < Math.min(a.length, b.length); i += 1) {
if (a.charCodeAt(i) === b.charCodeAt(i)) {
continue;
}
return a.charCodeAt(i) - b.charCodeAt(i);
}
return a.length - b.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment