type Person struct {
name string
age int
}
persons := []Person{
{
name: "jack",
age: 55,
},
{
name: "lucy",
age: 11,
},
{
name: "bob",
age: 33,
},
}
personIfs := []interface{}{}
for _, p := range persons {
personIfs = append(personIfs, p)
}
PickInt(func(person interface{}) int {
return person.(Person).age
}).Sort(personIfs, func(i, j int) bool {
return i < j
})
if personIfs[0].(Person).name != "lucy" || personIfs[1].(Person).name != "bob" || personIfs[2].(Person).name != "jack" {
t.Fail()
}-
Notifications
You must be signed in to change notification settings - Fork 0
License
Shilyx/picksort
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published