September 2015
Intermediate to advanced
268 pages
5h 35m
English
The fifth feature of our to-do application is to give users the ability to sort our list of tasks by priority and name. We will do this by adding the buttons, which will sort the tasks when clicked upon. This feature will demonstrate the built-in sort function of Knockout.
We will use the sort function of the observable array to sort our tasks. The following is the simplest example of using the sort function:
observableArray.sort();
This will sort observableArray alphabetically. This simple sort function is ideal for arrays of strings or numbers, but for an array of objects, such as our tasks array, we need to tell the sort function how it should compare objects. To do this, we pass a function to the sort function ...
Read now
Unlock full access