GO language program with example of Array Reverse Sort Functions for integer and strings
Simple program using StringSlice, IntSlice functions to Reverse Sort an Array.
Example
/// GO language program with Array Reverse
package main
import (
"fmt"
"sort"
)
func main() {
fmt.Println("Interger Reverse Sort")
num := []int{50,90, 30, 10, 50}
sort.Sort(sort.Reverse(sort.IntSlice(num)))
fmt.Println(num)
fmt.Println()
fmt.Println("String Reverse Sort")
text := []string{"Japan","UK","Germany","Australia","Pakistan"}
sort.Sort(sort.Reverse(sort.StringSlice(text)))
fmt.Println(text)
}
Output
Interger Reverse Sort
[90 50 50 30 10]
String Reverse Sort
[UK Pakistan Japan Germany Australia]
Most Helpful This Week
How to Convert Float to String type in Go?
How do you set headers in an HTTP response in Go?
Program in Go language to print Floyd's Triangle
Cannot convert <type1> to <type2> error in Golang
How do you handle HTTP timeouts with an HTTP client in Go?
Golang program for implementation of Random Maze Generator