Hi,
I have a couple of dropdownlist on page. They are all binded to knockout observablearray. I a dataadapter with datatype observablearray.
The content of the array is structured data (id, name, description). The field I’m displaying in the dropdown is the name. Unfortunately, the list is not sorted by name automatically.
What is the best approach to getting those list sorted? The approach, I’m thinking of using is the one below .e.i Using obervablearray.sort() and provide a function that will sort by name.
this.myobservablearray.sort(function(left, right) {
return left.name == right.name ? 0 : (left.name < right.name ? -1 : 1)
});
Is that the way to go? It seems to work well but maybe there is another way that you would suggest.
Thank you