Flips an array of objects into an object of arrays or vice versa