1 00:00:00,880 --> 00:00:03,980 In this self-check exercise we'd like to revisit 2 00:00:03,980 --> 00:00:06,320 what I mentioned in the preceding video 3 00:00:06,320 --> 00:00:08,960 about the fact that strings are sorted 4 00:00:08,960 --> 00:00:12,640 lexicographically as opposed to alphabetically. 5 00:00:12,640 --> 00:00:15,100 So again that means that we're sorting 6 00:00:15,100 --> 00:00:18,020 based on the underlying numberic values 7 00:00:18,020 --> 00:00:20,590 of the individual characters in the strings, 8 00:00:20,590 --> 00:00:23,150 not based on their letters. 9 00:00:23,150 --> 00:00:25,750 So for example, we want you to create 10 00:00:25,750 --> 00:00:28,550 a list of strings representing various foods 11 00:00:28,550 --> 00:00:29,600 that you see here, 12 00:00:29,600 --> 00:00:31,160 and notice that we have some of them 13 00:00:31,160 --> 00:00:32,730 with uppercase first letters 14 00:00:32,730 --> 00:00:35,470 and some of them with lowercase first letters. 15 00:00:35,470 --> 00:00:37,380 Then, once you've created that list, 16 00:00:37,380 --> 00:00:39,770 invoke its 'sort' method to see 17 00:00:39,770 --> 00:00:42,960 the sort order for that list. 18 00:00:42,960 --> 00:00:44,610 Give that a shot and then come back 19 00:00:44,610 --> 00:00:45,663 to see the answer. 20 00:00:50,220 --> 00:00:52,940 Okay, let's go ahead and create that list. 21 00:00:52,940 --> 00:00:55,010 So I'll expand my first cell here, 22 00:00:55,010 --> 00:00:57,160 and you can see we have just the list 23 00:00:57,160 --> 00:00:58,680 of strings that were specified 24 00:00:58,680 --> 00:01:00,700 in the problem statement with 25 00:01:00,700 --> 00:01:03,060 several of those strings having an 26 00:01:03,060 --> 00:01:04,710 uppercase first letter, 27 00:01:04,710 --> 00:01:07,430 and the next thing we would like to do is sort 28 00:01:07,430 --> 00:01:09,560 that list, and we're going to do an in-place 29 00:01:09,560 --> 00:01:12,000 sort for this particular exercise. 30 00:01:12,000 --> 00:01:14,080 Now, finally we want to take a look at 31 00:01:14,080 --> 00:01:17,200 what the actual order of those elements is, 32 00:01:17,200 --> 00:01:19,660 and when we evaluate that, we can see that 33 00:01:19,660 --> 00:01:21,640 the capitalized words up here 34 00:01:21,640 --> 00:01:23,280 in alphabetical order, 35 00:01:23,280 --> 00:01:25,610 followed by the lowercase words 36 00:01:25,610 --> 00:01:28,790 in alphabetical order, and the reason for that is 37 00:01:28,790 --> 00:01:31,660 the underlying character values 38 00:01:31,660 --> 00:01:35,810 in their numeric form for uppercase letters 39 00:01:35,810 --> 00:01:37,830 is lower than lowercase letters. 40 00:01:37,830 --> 00:01:40,715 So for example, lowercase A is 97, 41 00:01:40,715 --> 00:01:44,840 whereas uppercase A is 65, 42 00:01:44,840 --> 00:01:47,280 so uppercase B would be 66, 43 00:01:47,280 --> 00:01:49,380 and uppercase C would be 67, 44 00:01:49,380 --> 00:01:54,380 so B,C,G in order, again all capitals, 45 00:01:54,760 --> 00:01:57,070 and then when we go to the lowercase 46 00:01:57,070 --> 00:02:01,010 starting words they, too, are in ascending order, 47 00:02:01,010 --> 00:02:05,010 but the capital letters have lower overall values 48 00:02:05,010 --> 00:02:06,350 than the lowercase letters, 49 00:02:06,350 --> 00:02:08,610 so they appear first in the list. 50 00:02:08,610 --> 00:02:11,603 And that's your typical lexicographical sort.