Created
January 19, 2015 14:30
-
-
Save charlesponti/147778a0842338e0bd09 to your computer and use it in GitHub Desktop.
JavaScript Alphabetical sort
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
var alphabeticalSort = function(array) { | |
return array.sort(function(a, b) { | |
var A = a.toLowerCase(); | |
var B = b.toLowerCase(); | |
if (A < B) { | |
return -1; | |
} else if (A > B) { | |
return 1; | |
} else { | |
return 0; | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment