Python Challenges: Different methods for sorting lists part 1

Transcript

English (Auto-generated)

how is everybody? I hope everybody is doing very very well. So today wow. And for the next few podcasts we're gonna be stepping aside from our tickets toe challenge series if we're falling along to that and we're gonna start doing lists. We're gonna sorting list. A list is a very popular coding challenge especially for python. Um And there are a few methods that have become particularly well known for being efficient, easy and um Simple and efficient like I said previously very very efficient. So today we're going to be trying out one and we're gonna try one. I don't think this one specifically has the name for it because there are some ones that happening with bubble sort insertion swords and stuff like that. We're gonna cover those in um the next few videos but in this one we're just gonna do a very simple method of getting the smallest number in that list and adding it to the new list. Um and removing it from the original list. So then there's gonna be a new smaller one if that makes sense. Okay I hope I explained myself. Okay. Okay so first off we're gonna start off by making a new list that for right now is gonna be an empty list. Perfect. And then what we're gonna do is while the list isn't empty so there's very there's various ways you can check this but we're gonna do wow links of list does not equal zero. We're gonna do the phone. Okay so while that's doing that we're gonna make a variable called smallest and that's just going to equal min list. And then what we're gonna do is we're going to remove the smallest from the original list. So list. Don't remove smallest. Okay. And then we're gonna add it to the new list. So we're gonna do no list got depend and this is already gonna add it to the last um, to the end of the list. So we don't even have to worry about that. And then we can just return a new list. Return new list. Return no list. Like so. And now we are ready to try it out. Print sort list. And let's try it out with let's try out with 54 no 53 42. And let's see if it works. Okay. First, let's write like this. No 12. Okay. Now we're gonna get open up our terminal, new terminal. It's taking a while to get load. Okay. And then we're gonna do Python three sorting in the beginning of our file sorting list. That's okay. And no such victory. Hmm. Because I'm just gonna make part of writing code. No. Okay. There you go. And ready up and 12345. Perfect. And what we're gonna do is that we're gonna try out if it works if number repeat themselves because that's an important factor in 12345. Perfect. So, as you can see this is one way of sorting list. I encourage you guys massively to try to find ways two factors or to find ways to sort list yourselves. And then in future videos, we can you guys can see if you guys used one of the popular methods or if you guys came up with a completely unique method of solving this. So thank you so much for joining this, and we'll sort your list in the future by.
15 Views 0 Likes 0 Comments

Title says it all, we are going to make a small series explaining the different methods for sorting lists

Comment
Leave a comment (supports markdown format)