I'm completely new to JavaScript; please feel free to correct me on my technical terminology.
I have a set of key value pairs that are being appended to a list. The list is displayed as a dropdown menu where the values of the keys are the displayed options and the keys are included in the HTML tag. My boss has asked me to alphabetically sort those displayed values.
So far, I have iterated through the object with a for...in loop and extracted each key's value into an array. I sorted the array and I can now append the values to the list alphabetically.
What's the best way to keep the keys linked to their respective values, so that when I append the values their appropriate keys can be added as well?
Thanks.
SHORT VERSION: How do I match keys back to their values after copying all values into an array and alphabetically sorting it?