I have a list items which are draggable and each one has data id attribute so I can detect their order.
So in normal order they look like this:
<ol>
<li data-id='0'>Apple</li>
<li data-id='1'>Banana</li>
<li data-id='2'>Cake</li>
<li data-id='3'>Tea</li>
<li data-id='4'>Biscuit</li>
</ol>
I also have an array the same length as the number of list items which contains data for each list item and its in normal order on the beginning just like the list items.
So after some of my list items are dragged, their order changes, so I need to reorder the data in my array in the same way.
So lets say some list items have been dragged and their order (which I can detect with data-id attribute) now looks like this:
<ol>
<li data-id='0'>Apple</li>
<li data-id='2'>Cake</li>
<li data-id='1'>Banana</li>
<li data-id='4'>Biscuit</li>
<li data-id='3'>Tea</li>
</ol>
So I need to change the order in my array the same way.
How can I achieve that?