Created
October 15, 2014 19:49
-
-
Save ryanseys/34ce9137a8aee3cd208c to your computer and use it in GitHub Desktop.
Google 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
function googlesort(a, b) { | |
var order = ['1', 'S', 'Galaxy', 'Q', '7', '4', '10', '5', '6']; | |
return order.indexOf(a) > order.indexOf(b); | |
} | |
console.log(['10', '6', '5', '4'].sort(googlesort)); | |
// [ '4', '10', '5', '6' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment