‫All right.
‫It feels like it's never going to end.
‫We have so many methods with lists, but like I said, lists have a lot of methods because you can do
‫a lot with them.
‫It seems like a lot right now.
‫But trust me, these are going to become second nature.
‫So hang in there.
‫I have a few more to show you.
‫The next one is called Sort.
‫Guess what sort is going to do if I click Run?
‫I get none.
‫Hmm.
‫But remember, sort of sorts the list, as you can imagine, in place that means and modifies the list.
‫So if I remove this up to here and then do sort or do basket and I click Run.
‫Look that I get a sorted list where Dee was moved in front of E.
‫If I add let's say X at the beginning here.
‫And I click Run.
‫It's going to move the ex all the way to the end.
‫It's going to sort the list in place for me again.
‫If I hover over it, sees that it's going to not return anything, which is why our print initially
‫didn't work.
‫We had to print our basket, not whatever this produces, which it doesn't produce anything.
‫Hmm.
‫But what about this one?
‫If we go to built in functions, I have something called sorted.
‫And if I do sorted and because it's a function, not a method, I can do sorted, dot or basket.
‫So around.
‫The brackets, just like print.
‫If I run this.
‫All right, nothing has changed.
‫But what if I remove this and put it in here?
‫If I click run, I get a, b, c, d, e, x.
‫What if I comment this out?
‫So that we're not sorting it anymore.
‫We just have the basket and then we run this sorted.
‫Function if I run.
‫Did you see that?
‫Sorted.
‫I know it's confusing.
‫Why do they even have to?
‫But sorted produces a new array.
‫So if I do print basket here and I click run.
‫The basket hasn't been modified.
‫The basket still remains the same.
‫It's this one over here that's not sorted.
‫Sorted, on the other hand, doesn't modify the basket in place.
‫Instead, it creates a new copy of the basket and sorts it.
‫It's almost as if we're doing this.
‫We're saying new basket equals basket, and then we're going to copy that basket, remember list slicing
‫and then we're performing New Basket sort on this new list so that if I do New Basket and I click Run.
‫We get the same thing.
‫So you have to be careful of certain actions that perform an action in place or create a completely
‫new list to begin with.
‫By the way, there's also, instead of this, a dot copy method that we can use.
‫And if I run this.
‫Again.
‫We get the same thing.
‫Copy.
‫Just as the name suggests.
‫Copy the list for us and returns for us a new list.
‫All right, one last one and that is basket dot reverse.
‫What do you think this does based on the name?
‫Well, if I check out the basket here and click Run.
‫Is that what you expected?
‫It reverses the basket.
‫In place.
‫But notice that it's not like sort.
‫It's not sorting.
‫It's simply switching all the indexes into opposite sides.
‫So DX is now index of zero.
‫E is now index of one.
‫Index of two three, so on and so forth.
‫So you can see here that it doesn't actually sort it.
‫Instead, what we might want to do is sort first, then reverse.
‫And if we click Run.
‫We have a sorted, reversed basket.
‫This is a little tricky one that some interviewers might ask.
‫All right.
‫Good job getting this far.
‫We're almost done with lists.
‫So I'll see you in the next video.
‫Bye bye.