create transpose function that transposes an array