Core: Allow more than 2 arrays for merge function.

Fixes #14982