Skip to content

Shilyx/picksort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

picksort

	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()
	}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages