feat: add ShellSort

This commit is contained in:
dudaodong
2022-01-14 18:17:46 +08:00
parent d491bea263
commit 43e0ca7edf
2 changed files with 39 additions and 1 deletions

View File

@@ -110,3 +110,16 @@ func TestSelectionSort(t *testing.T) {
asssert.Equal(expected, actual)
}
func TestShellSort(t *testing.T) {
asssert := internal.NewAssert(t, "TestShellSort")
comparator := &peopleAageComparator{}
sortedPeopleByAge := ShellSort(peoples, comparator)
t.Log(sortedPeopleByAge)
expected := "[{d 8} {b 10} {c 17} {a 20} {e 28}]"
actual := fmt.Sprintf("%v", sortedPeopleByAge)
asssert.Equal(expected, actual)
}