Sort List

Examples Filter
package main

import (
	"fmt"
	"sort"
)

func main() {

	fruit := []string{"Apple", "Banana", "Mango", "Orange"}

	// Custom sort based on the second letter of the word.
	sort.Slice(fruit, func(i, j int) bool {
		return fruit[i][1] < fruit[j][1]
	})

	fmt.Println(fruit)
}
Last Run  :
[Banana Mango Apple Orange]
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort(); 
console.log(fruits);

fruits.reverse();     // Then reverse the order of the elements
console.log(fruits);

// Custom sort
var complexList = [{prop: 1}, {prop:100}, {prop:23}];
complexList.sort(function(a, b){return a.prop - b.prop});
console.log(complexList);