thecasualcoder/godash

Add GroupBy function

aswinkarthik opened this issue · 1 comments

API

john := Person{name: "John", age: 25}
doe := Person{name: "Doe", age: 30}
wick := Person{name: "Wick", age: 25}

input := []Person{
   john,
   doe,
   wick,
}

var output map[int][]Person

godash.GroupBy(input, &output, func(person Person) int {
    return person.age
})

// output is
// { 25: [john, wick], 30:  [doe] }

I will try to add this.