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
Example to use various String Functions in Go Language
GO language program with example of String Compare function
Program in Go language to Find Largest Element of an Array
Program in Golang to print Pyramid of Numbers
Program in Go language to print Pascal's Triangle
How to use struct that is imported from another package?