Insertion in sorted multi-dimensional array.
Requirement:
There is a multidimentional sorted array as shown below:
If user changes sort index of existing product then auto update relevant product's sort index. e.g.
If there are six products with respective sort ids as 1,2,3,4,5,6.
If user changes Product2's sort index to 6 then :
Product id............Sort Index
-------------------------------------------
Product1............1
Product2............2 <-- 6
Product3............3
Product4............4
Product5............5
Product6............6
Result after changing sort index to 6 for Product 2:
Product id............Sort Index
-------------------------------------------
Product1............1
Product3............2
Product4............3
Product5............4
Product6............5
Product2............6
As we can see, the other array elements are auto adjusted.
One can certainly program it, but do anybody have done this before, if so can you please guide or provide sample code?
|