package main import ( "fmt" ) func main() { a := [...]int{12, 32, 434, 765, 34, 8, 94, 12, 34, 53} num := len(a) fmt.Println(a) for i := 0; i < num; i++ { for j := i + 1; j < num; j++ { if a[i] < a[j] { temp := a[i] a[i] = a[j] a[j] = temp } } } fmt.Println(a) }
[ `go run test1.go` | done: 195.80006ms ]
[12 32 434 765 34 8 94 12 34 53]
[765 434 94 53 34 34 32 12 12 8]