Working as intended. When you collect items, it goes to the first available slot. So logically, the last slot would have the fewest?
It might not be a bug however I think that if it sorted the item with least quantity at the top it would make more sense. Yes when you loot items it goes to the first available slot hence that will usually end up being a slot in below the rest of your items which is perfectly fine. However the item sort is a feature to sort your items and when you use potions it will start at the first available stack in your inventory, so if you don't move your lowest quantity stack to the top after sorting your items you will end up 1 stack taking up 2 slots at times. I don't see how this would affect you collecting items in any negative way, when you loot items and you have a stack of 5 at the top of your inventory it will start filling that till its full and next stack will start filling from the first available slot as it does now.