Groups the elements of a sequence.
Simple
Enumerable.create("grape", "passionfruit", "banana",
"apple", "blueberry")
.groupBy('x => x[0]')
.each(function(grouping) {
// grouping[0].key = 'g'
// grouping[0][0] = 'grape'
// grouping[1].key = 'p'
// grouping[1][0] = 'passionfruit'
// grouping[2].key = 'b'
// grouping[2][0] = 'banana'
// grouping[2][1] = 'blueberry'
// grouping[3].key = 'a'
// grouping[3][0] = 'apple'
});
With equality comparer
Enumerable.create("grape", "passionfruit", "banana",
"apple", "Blueberry")
.groupBy('x => x[0]', 'x, y => x === y')
.each(function(g) {
// grouping[0].key = 'g'
// grouping[0][0] = 'grape'
// grouping[1].key = 'p'
// grouping[1][0] = 'passionfruit'
// grouping[2].key = 'b'
// grouping[2][0] = 'banana'
// grouping[3].key = 'a'
// grouping[3][0] = 'apple'
// grouping[4].key = 'B'
// grouping[4][0] = 'Blueberry'
});