-
Notifications
You must be signed in to change notification settings - Fork 0
/
sorts.go
62 lines (43 loc) ยท 1.98 KB
/
sorts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package emojis
import (
"fmt"
"sort"
)
// =============================================================== For the 'ListOfEmojis' type ===============================================================
// Defining a function named 'SortAlphabetically' to sort 'loe' emojis list in alphabetical order...
func (loe *ListOfEmojis) SortAlphabetically() {
// Allocation of all necessary memory for the 'slugs' []string...
slugs := make([]string, 0, len(loe.mapOfEmojis))
// Initialization of the first loop of this function...
for s := range loe.mapOfEmojis {
// Put the 's' string (current slug) in the 'slugs' []string...
slugs = append(slugs, s)
}
// Sort the slice containing the slugs in alphabetical order...
sort.Strings(slugs)
// Initialization of the second loop of this function...
for s := range slugs {
// Display the concerned emoji...
fmt.Println(loe.mapOfEmojis[slugs[s]])
}
}
// Defining a function named 'SortReverseAlphabetically' to sort 'loe' emojis list in reverse alphabetical order...
func (loe *ListOfEmojis) SortReverseAlphabetically() {
// Allocation of all necessary memory for the 'slugs' []string...
slugs := make([]string, 0, len(loe.mapOfEmojis))
// Initialization of the first loop of this function...
for s := range loe.mapOfEmojis {
// Put the 's' string (current slug) in the 'slugs' []string...
slugs = append(slugs, s)
}
// Sort the slice containing the slugs in reverse alphabetical order...
sort.Sort(sort.Reverse(sort.StringSlice(slugs)))
// Initialization of the second loop of this function...
for s := range slugs {
// Display the concerned emoji...
fmt.Println(loe.mapOfEmojis[slugs[s]])
}
}
// => YOU MUST DEFINE AND DEVELOP SOME SORT FUNCTIONS FOR THE 'LISTOFEMOJIS' TYPE...
// =============================================================== For the 'ListOfCategories' type ===============================================================
// => YOU MUST DEVELOP SOME STATISTICAL CALCULATION FUNCTIONS FOR THE LISTOF'CATEGORIES' TYPE...