Question: Manually change order of a JavaScript array


Manually change order of a JavaScript array

Answers 0
Added at 2017-01-04 20:01

I am looking for a JavaScript/Jquery solution is re-ordering an array based on manual changes.

I have an existing array consisting of different groups:

 var my_groups =  ["group 1", "Group2", "group3", "group4", "group 5"]

I want to change the order of this array based on a manual changes. These groups do not have any alphabetical/nummerical order. I want to manually decide which group will go first, second, third etc.

My idea is to create 5 different dropdowns (one for each group) which are each populated with all the group names. Once I fill in all the dropdowns with the different groups, a new array is created that is based on the order given in the 5 dropdowns. Please note that this needs to be done visually where one can see what order he is putting the groups in. This is done to determine the order of play of groups for a sports tournament system.

Would anybody know how to do this JavaScript/JQuery? Would you have any other suggestions? I have little JavaScript experience.

Answers to

Manually change order of a JavaScript array

Source Show
◀ Wstecz