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
Golang program for implementation LIFO Stack and FIFO Queue
What is an HTTP client in Go?
How do you catch panic in Golang?
Invalid operation: <variable> (type <type>) does not support indexing error in Golang
Example to compare Println vs Printf
Modernizing Legacy Applications: Critical Tips for Organizational Upgrades