A function that groups/splits an array by the values of a given key or keys.