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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -