Exemplo n.º 1
0
func ints() {
	data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586}
	a := mySort.IntArray(data)
	mySort.Sort(a)
	if !mySort.IsSorted(a) {
		panic("fail")
	}
	fmt.Printf("The sorted array is : %v\n", a)
}
Exemplo n.º 2
0
func strings() {
	data := []string{"monday", "friday", "tuesday", "wednesday", "sunday", "thursday", "", "saturday"}
	a := mySort.StringArray(data)
	mySort.Sort(a)
	if !mySort.IsSorted(a) {
		panic("fail")
	}
	fmt.Printf("The sorted array is : %v\n", a)
}
Exemplo n.º 3
0
func days() {
	Sunday := day{0, "SUN", "Sunday"}
	Monday := day{1, "MON", "Monday"}
	Tuesday := day{2, "TUE", "Tuesday"}
	Wednesday := day{3, "WED", "Wednesday"}
	Thursday := day{4, "THU", "Thursday"}
	Friday := day{5, "FRI", "Friday"}
	Saturday := day{6, "SAT", "Saturday"}
	data := []*day{&Tuesday, &Thursday, &Wednesday, &Sunday, &Monday, &Friday, &Saturday}
	a := dayArray{data}
	mySort.Sort(&a)
	if !mySort.IsSorted(&a) {
		panic("fail")
	}
	for _, d := range data {
		fmt.Printf("%s ", d.shortName)
	}
	fmt.Printf("\n")
}