Created
September 3, 2012 19:48
-
-
Save linuxbender/3612815 to your computer and use it in GitHub Desktop.
javascripts
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
foo.slice(0, foo.length - (foo.length - baa.length)) |
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
{ | |
"id": 96, | |
"location": "Kentucky", | |
"name": "Wildcats", | |
"abbreviation": "UK", | |
} | |
ko.observableArray.fn.sortByProperty = function(prop) { | |
this.sort(function(obj1, obj2) { | |
if (obj1[prop] == obj2[prop]) | |
return 0; | |
else if (obj1[prop] < obj2[prop]) | |
return -1 ; | |
else | |
return 1; | |
}); | |
} | |
vm.teams.sortByProperty("name"); | |
vm.teams.sortByProperty("location"); | |
vm.teams.sortByProperty("abbreviation"); | |
vm.teams.sortByProperty("id"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment