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