I'm working on sorting and reindexing a sample list that is currently unordered but numbered.
<ul>
<li>0001 - Apple</li>
<li>0002 - Banana</li>
<li>0003 - Mango</li>
</ul>
My goal is to rearrange the list so that "0001 - Apple" moves down in the order, like this:
<ul>
<li>0002 - Banana</li>
<li>0003 - Mango</li>
<li>0001 - Apple</li>
</ul>
However, the desired final order should be as follows:
<ul>
<li>0001 - Banana</li>
<li>0002 - Mango</li>
<li>0003 - Apple</li>
</ul>
During this process, I encounter issues when moving items up or down one row within the list.
<ul>
<li>0002 - Mango</li>
<li>0001 - Banana</li>
<li>0003 - Apple</li>
</ul>
For example, if I move an item up one row:
<ul>
<li>0002 - Mango</li>
<li>0003 - Apple</li>
<li>0001 - Banana</li>
</ul>
The indexes for each item need to remain consistent as "0001," "0002," and "0003," respectively.
This movement action should be initiated by buttons for upward or downward movements.