groupby troubles

Nov 7, 2013 at 4:00 PM
I have an array of objects that looks something like this:
var cart = [{sku:55555, customer:84848},{sku:55555, customer:84848},{sku:44444, customer:84848},{sku:33333, customer:84848},{sku:33333, customer:84848},{sku:22222, customer:343434},{sku:55555, customer:84848}]
I'd like to create a grouping that results in a three column output of unique customer / sku combinations and quantity count.

example:
sku | customer | count
55555 | 84848 | 3
44444 | 84848 | 1
33333 | 84848 | 2
22222 | 343434 | 1

The only way I've been able to produce this result looks hacky. PLEASE let me know if there is a better way because i'm sure there is...
$.Enumerable.From(cart)
                        .GroupBy("$.customer +'|-|' + $.sku","","k,e => { key:k,ct:e.Count()}").Select(function (k){return {customer:k.key.split('|-|')[0],sku:k.key.split('|-|')[1],count:k.ct}}).ToArray()
Originally i was trying something like this:
.GroupBy("{customer:$.customer,sku:$.sku}")
but it gave me duplicates instances of those combinations in the group by which resulted in counts of '1' in the select statement.