I'm trying to create a function that 'drags' a sequential number of elements to a new location within the array, constrained to the current size of the array. Other items should jiggle round the 'dragged' items.
For example, if my array has 7 elements and I want to drag the middle three...
1, 2, 3, 4, 5, 6, 7 <-- keys
a, b, C, D, E, f, g <-- values
The uppercase chars are the ones I want to 'drag'. If I drag to start of the array (drag to 1) the array would look like this:
1, 2, 3, 4, 5, 6, 7 <-- keys
C, D, E, a, b, f, g <-- values
If I drag to position 5 (or above - can't be dragged outside current array size) the array would look like this:
1, 2, 3, 4, 5, 6, 7 <-- keys
a, b, f, g, C, D, E <-- values
Any idea how I can achieve that using Lua in a non-crufty manner?