javascript - Populate a combo from a json hash but in sorted order -
I have a JSON hash and I populate the combo box as follows:
< Code> $ each (json_hash, function (key, value) {$ ("#selected"). Append ("& lt; option value = '" + key + "'> gt; + + value +" & lt; / Option & gt; ");});It works fine but the problem is that it does not show data in sequential order.
The easiest way I can populate the combo so that the data can be sorted in a sequential order?
Add it to your code before
json_hast.sort (function (A, b) {return a.value - b.value});
Comments
Post a Comment