knockout.js - Knockoutjs better list example sort not working with new items -
Here, in the example, when I add "trees" and "bees" sort, these original objects are two new Separate observable array from items.
to replace this.sortItems = function, based on the answer to mckeejm, how do we fix it, or is it a known bug? () {This.allItems.sort (); }; With
this.sortItems = function () {this.allItems.sort (this.sortFunction); }; See http://stackoverflow.com/questions/6965951/sorting-an-observablearray-for-one-of-the-templates // and http://jsfiddle.net/rniemeyer/93Z8N/ this.sortFunction = function (A, b) {return a.toLowerCase () & gt; B.toLowerCase ()? 1 1; };
This is not a bug, it's ASCII-based sorting. The upper case starts with a letter 65, and starts with lower case 97. Try "twenty" and "tree" and you will see the difference.
Comments
Post a Comment