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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -