In this self-check exercise we'd like to revisit
what I mentioned in the preceding video
about the fact that strings are sorted
lexicographically as opposed to alphabetically.
So again that means that we're sorting
based on the underlying numberic values
of the individual characters in the strings,
not based on their letters.
So for example, we want you to create
a list of strings representing various foods
that you see here,
and notice that we have some of them
with uppercase first letters
and some of them with lowercase first letters.
Then, once you've created that list,
invoke its 'sort' method to see
the sort order for that list.
Give that a shot and then come back
to see the answer.
Okay, let's go ahead and create that list.
So I'll expand my first cell here,
and you can see we have just the list
of strings that were specified
in the problem statement with
several of those strings having an
uppercase first letter,
and the next thing we would like to do is sort
that list, and we're going to do an in-place
sort for this particular exercise.
Now, finally we want to take a look at
what the actual order of those elements is,
and when we evaluate that, we can see that
the capitalized words up here
in alphabetical order,
followed by the lowercase words
in alphabetical order, and the reason for that is
the underlying character values
in their numeric form for uppercase letters
is lower than lowercase letters.
So for example, lowercase A is 97,
whereas uppercase A is 65,
so uppercase B would be 66,
and uppercase C would be 67,
so B,C,G in order, again all capitals,
and then when we go to the lowercase
starting words they, too, are in ascending order,
but the capital letters have lower overall values
than the lowercase letters,
so they appear first in the list.
And that's your typical lexicographical sort.