Group subarrays based on column value

I have an array: [[‘a’, 1], [‘b’, 1], [‘c’,2], [‘d’,2]] How can I group the subarrays based on the second column value like this: [[[‘a’, 1], [‘b’, 1]], [[‘c’,2], [‘d’,2]]] I have an idea to solve …