Go language - Lesson 46 - sort words by custom alphabetical order (Beginner programmer's tutorial)

Go language - Lesson 46 - sort words by custom alphabetical order (Beginner programmer's tutorial)

How do I sort words in Alphabetical order?
How do I sort words in reverse alphabetical order?
I don't want the words starting with a capital letter to come before all words starting with lowercase letters?
How do I customize how words are sorted?

What is the purpose of the Sort function in the sort package?
What is the purpose of the Strings function in the sort package?
What are these interfaces in the sort package for?

In this video, I sort a few words in alphabetical order. I show how the sort package sorts text usually, and how you would want to customize it if you were making a dictionary.

Now, that we have some experience using interfaces (from lesson 42), I can teach you how to customize the sorting behaviour when using the standard library.

Why should I learn this?
Sorting text is a common task in real life. Learning how to do it using a computer is also useful once there are many words to sort. While it is possible to write our own functions to sort text, and this is a very useful learning exercise. In most cases, you want to use the standard library to save time, and money. In this video, we learn how to use the standard library to sort words. The skills taught in this video do not only apply to the task of sorting. Many packages require us to use interfaces in our source code in a similar way, and seeing how to use interfaces to customize a sort is a stepping stone to many more useful tasks in the future.

Concepts Demonstrated:
- uppercase versus lowercase letters
- ignoring case when sorting
- converting a word to lowercase letters
- defining a custom sort
- how to implement an interface
- how to read documentation
- how to read source code in the standard library


#Golang

languageLessonwords

Post a Comment

0 Comments