I have a JavaScript object like this:
[{"a":1,"b":2},{"a":1,"b":3},{"a":2,"b":4},{"a":2,"b":5}]
I want to group this object field 'a' and want something like this:
[{"a":1,"values":[{"a":1,"b":2},{"a":1,"b":3}]},{"a":2,"values":[{"a":2,"b":4},{"a":2,"b":5}]}]
I have a JavaScript array of more than few thousands elements. What is the most efficient way to achieve this?