Quick snippet, I found problems with sorting loot since I saved 6 bps of bps of loot from serpent spawns, to help with organising it I used this, and figured it may be helpful.

local itemname = "serpent sword" -- Item to move
local bpfrom = "purple backpack" -- Backpack to move it from
local bpto = "jewelled backpack" -- Backpack to move it to
local mincap = 41 -- Minimum cap to move it - useful if you just wanna cap out on that item

while (itemcount(itemname, bpfrom) > 0) and getcontainer(bpto).usedslots < getcontainer(bpto).maxslots and cap > mincap do
    moveitems(itemname, bpfrom, bpto, 100)
wait(200, 400)
Thanks to Arv, Sirmate and Dehan.