Last active
August 29, 2015 14:21
-
-
Save adnasa/73ed5d3b4459badbdecf to your computer and use it in GitHub Desktop.
Quite wierd
This file contains hidden or 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
addresses = _.sortBy(addresses, function(address) { | |
addressEntity = address.address; | |
var reducedKey; | |
reducedKey = ['name', 'city', 'zipCode'].reduce(function(previous, current) { | |
if (previous && addressEntity.hasOwnProperty(previous) && addressEntity[previous]) { | |
return previous; | |
} else if (current) { | |
return current; | |
} | |
}); | |
return addressEntity[reducedKey]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment