 Hey, what's going on guys ruling out here coming back at you with some more Python tutorials? Let's get idle started up and we can get to programming. I'm gonna create a new script here save this as a filed up Python Start up with a shebang line Create a new class Get our comments going on if you want to have that sort of code block style like I do Create your constructor bringing the self keyword makes your caps lock is off. We can just display Hello world get some new lines in there and I will test Whether or not this is the correct script that we are running with Now I can set a root object to be an instance of the base class. If we run this that should be fine. Okay, cool Now the thing that we're talking about today is the is the sordid function Now the sordid function along with the along with the sort function Which is an attribute or at least something that you can do with objects of tuples and arrays and that sort of thing is is being able to Sort the array obviously and it normally would be in descending order at least ascending order Sorry, because if you would have if you use sordid You can pass in an array of numbers. Let's say 3 10 negative 2 negative 3 negative 2 whatever I can change it if I want to one and then Thank you for one that sort of thing and that would return the the array and the way in the form that you wanted it to be in It would in turn be negative 2 1 3 and then 10 Because it would sort them in the correct order now you can do this with strings as well when you're working with like a Let's see this is And then like you could just call it a string array or that sort of thing you could sort this and Then it would sort it in the way that it would expect it to be except and it's an alphabetical order would be a and then is This and that sort of thing so yeah All it is is really just moving with them moving them into the order that they should be and they're sorting them So let's try and create this on our own though This is has a little bit more of an interesting algorithm or an interesting logic flow, so let's try it out Let's define a new function to find sort Remember we need the self keyword because we're defining a function inside of an of an object and we'll pass in the array that we're gonna be looking through We do need the array length because we're going to be counting and going through the going through the array numerically So array equals length of array that keeps it easy and now we'll start doing our for loop now I need for I in range obviously we're going through the entire array, so we need array dot length and then Once you've got that for loop set up We're going to actually need another for loop and this is what's going to allow us to be able to go back and forth with the array And that sort of thing so we're going to be able to make sure it's ordered. Sorry that it's sorted So for J in range and now we're gonna want to start with I or the current thing that we're working with and then go until the end of the array So we've got this set up We can test whether the array variable of I or at least array with the index of I whatever is that we're looking at currently is Greater than the array variable of J Or the array at index J So with those numbers if one of them is greater you're going to be able to know that you should shuffle things around So what we do here is we create a temporary variable and that allows us to be able to manipulate one thing to the other You can like move one piece of information in a different direction and that sort of thing temporary becomes array with the index of I and Then array J actually array I sorry becomes array J and You guessed it array J Becomes our temporary variable Because we've shuffled these things around a bit. We've all we've done is created it in order that is sorted numerically So if we break out of this loop We can return our array So if we go up here We do we get ourselves a new structure or like a list. I'm gonna call it structure for now And it's gonna be just maybe a negative 421 negative 321 negative 300 negative 3423 that sounds about right negative four how about a zero how about maybe 23 Maybe two hundred and two thousand three hundred sixty five I'm going in order myself now. Well, this is embarrassing Let's move these in any Okay, it's not all in order. I wasn't I wasn't doing that bad. Okay. Let's just do 90 here So, okay, let's try that self dot structure. That's all set. So if we print out The way we would normally be able to do this sorted And then we just pass in self dot structure and then we can try and print out the way we've done it Which is practically the same thing with our sort function Self dot short remember because it's a local local function to this object and then we can pass in our self dot structure variable Now when we run this we have the exact same output because we're practically using that algorithm In fact, it's very likely that we are all we're doing is looping through the array and Seeing anything that's greater than the others and moving it further and further down the list. So yeah, that's all It's definitely something to be working with when you're when you're checking out strings though That might be a little bit more difficult and it's it's worth a lot more thought So that's definitely on its way though But for now you can enjoy this sort of algorithm and you see how one of those function works one of those functions work and Yeah, there you go. Thank you for watching guys. Thank you for listening. It'd be cool if you could leave a comment, let me know what you think of the video and Maybe leave a like maybe subscribe. I don't know it's it's all up to you But thanks again for watching guys, and I'll see you in the next tutorial