I have an observable array in Knockout of person objects. I wanted to be able to sort the list of persons based on the last name. The problem is the list has a number of duplica
If you make sure your players.json
returns the names sorted, you'll be fine. If it's loading them from a database, you need to add the first name field to your ORDER BY
clause.
If you want to do the sorting in Javascript, you could do it right after you load it from the service:
players.sort(function(player1, player2) {
return player1.lastname.localeCompare(player2.lastname) ||
player1.firstname.localeCompare(player2.firstname);
});