Groupby for regular array

Never mind. There is already a good post.