I made a mistake on my initial posting of my inventory sorting scripts:
The loop that went through the items was supposed to start like:
- for(int j = containerItems.Count-1; j >= 0; j--)
but I inadvertently had written it like:
- for(int j = containerItems.Count; j >= 0; j--)
Sorry about the mixup!