github.com/alexandrestein/gods@v1.0.1/examples/sort.go (about)

     1  // Copyright (c) 2015, Emir Pasic. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package examples
     6  
     7  import "github.com/alexandrestein/gods/utils"
     8  
     9  // SortExample to demonstrate basic usage of basic sort
    10  func SortExample() {
    11  	strings := []interface{}{}                  // []
    12  	strings = append(strings, "d")              // ["d"]
    13  	strings = append(strings, "a")              // ["d","a"]
    14  	strings = append(strings, "b")              // ["d","a",b"
    15  	strings = append(strings, "c")              // ["d","a",b","c"]
    16  	utils.Sort(strings, utils.StringComparator) // ["a","b","c","d"]
    17  }