When in creative mode, swapping items in the inventory does not work well.
Let's say I have a stack of dirt in slot 1 and a stack of diamond in slot 2.
Open the inventory, hover on the diamond and press 1 to swap.
After updating (e.g. placing a block) I end up with 2 stacks of dirt!
See this video.