Items are automatically sorted and merged in chests and cargo wagons.
Providing the player with new tools or adjusting the game interface, without fundamentally changing gameplay.
More than just chests.
idk if you're aware but another mod uses the same event and merge function: https://mods.factorio.com/mod/more-sorting