1 00:00:07,940 --> 00:00:14,220 Welcome back. What if we don't want to sort from the smallest item to the largest, 2 00:00:14,220 --> 00:00:18,375 but instead we want the reverse order? Well, that's easy. 3 00:00:18,375 --> 00:00:20,820 You've already seen how you can reverse a list, 4 00:00:20,820 --> 00:00:26,170 was actually a reverse function or you could do a list accumulation. 5 00:00:26,170 --> 00:00:30,140 But, it's actually even easier than that because we can 6 00:00:30,140 --> 00:00:34,805 specify an optional parameter for the sorted function called reverse. 7 00:00:34,805 --> 00:00:37,880 That's an optional parameter its default value, 8 00:00:37,880 --> 00:00:41,800 if you don't provide a value for it, it is false. 9 00:00:41,800 --> 00:00:44,680 But if you pass the value true in, 10 00:00:44,680 --> 00:00:47,435 you get the list back in the opposite order, 11 00:00:47,435 --> 00:00:51,780 you can see that on line number two. 12 00:00:52,240 --> 00:00:54,980 In addition to saying, 13 00:00:54,980 --> 00:00:57,270 what list we want to sort, 14 00:00:57,270 --> 00:01:03,075 we're also saying that the reverse parameter should get the value true. 15 00:01:03,075 --> 00:01:08,685 When we do that, we'll get the things in reverse order, 16 00:01:08,685 --> 00:01:11,945 Cherry, Blueberry, then Apple. 17 00:01:11,945 --> 00:01:14,975 I hope I'm not making it too hungry with these examples. 18 00:01:14,975 --> 00:01:20,630 So, this reverse equals true is just passing a parameter, 19 00:01:20,630 --> 00:01:24,200 the usual thing that we've seen before for functions. 20 00:01:24,200 --> 00:01:27,035 The actual value that we're passing in here, 21 00:01:27,035 --> 00:01:30,230 the word true is just a Boolean value, 22 00:01:30,230 --> 00:01:32,945 if you'll recall from when we were doing Boolean values. 23 00:01:32,945 --> 00:01:34,435 I could change this. 24 00:01:34,435 --> 00:01:36,915 Instead of passing the Boolean value true, 25 00:01:36,915 --> 00:01:39,285 I could pass the Boolean value false, 26 00:01:39,285 --> 00:01:45,719 and I would say, "Don't give this back in reverse order, not reversed." 27 00:01:45,719 --> 00:01:48,765 So, we would get Apple, Blueberry, and Cherry. 28 00:01:48,765 --> 00:01:54,589 Now, false is the default value for the reverse parameter. 29 00:01:54,589 --> 00:01:58,400 So, if I leave it out entirely, 30 00:01:58,400 --> 00:02:03,395 I get the same thing that I would get is if I say, "Reverse equals false." 31 00:02:03,395 --> 00:02:05,250 So, if I don't want it reversed, 32 00:02:05,250 --> 00:02:06,350 I don't have to say it. 33 00:02:06,350 --> 00:02:08,035 If I do want it reversed, 34 00:02:08,035 --> 00:02:11,380 I have to say "Reverse equals true." 35 00:02:11,440 --> 00:02:14,945 I get it in the reverse order. 36 00:02:14,945 --> 00:02:18,785 So, that's sorting a sequence in the opposite or the reverse order. 37 00:02:18,785 --> 00:02:22,385 I'll see you next time when we specify a custom order for sorting, 38 00:02:22,385 --> 00:02:26,760 based on some property of the items that are getting sorted.