JSFiddle - React, Tailwind, and code Playground
by infatti
HTML
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js"></script>
<ul data-bind="foreach: allItems">
<li>
<span data-bind="text: name"> </span>
</li>
</ul>
<button data-bind="click: sortItems">Sort</button>
JavaScript
var ListSortModel = function () {
this.allItems = ko.observableArray([
{ name: 'Denise' },
{ name: 'Charles' },
{ name: 'Bert' }
]); // Initial items
this.sortItems = function() {
this.allItems(this.allItems().sort(function(a, b) { return a.name > b.name;}));
};
};
ko.applyBindings(new ListSortModel());