You just modify your dropping method to drop at specific inventory indices, for example, if the first slot in the inventory is slot 0, then the first on the second line would be 4. So using basic maths principles you can create an algorithm to do the drop > 1 down drop > repeat method you've shown in your second gif.