When you click to merge items together, the icon become sort after. Sometimes you can misclick the sort button and you have to spend a bit of time reorganizing your inventory. Or lock slots so they won't be affected by the sort feature. E.g. locking first X slots in a tab so those items will not be reordered.