 Okay, in the last tutorial we created a PHP file that read a text file line by line, and that's the output of it right up here. And today we're going to do basically the same exact thing, but we're going to sort it so the list is alphanumeric, and then at the end we'll go and reverse sort it. So real quick, in the previous tutorials I mentioned how you can use whatever programming language you want when it comes to server-side scripts, obviously some are more suitable for server-side scripts, but you can write stuff in C if you want it for server-side programs. And you can also use shell scripts, now you can call shell scripts directly, or the way I've done it a lot lately is calling them from within my PHP code. So quickly I'm going to create a PHP file called sort.php, I'm going to put in my PHP tags here, and then I am going to close my PHP tag, and I gave it the system command here so I can put in a command line command here, and I'm going to give it the sort and the name of the file that I want to sort, and if you're familiar at all with shell scripts or Unix command line, you know, sort will sort that alphabetically. So if I was to save this and go here and go into our sort PHP file, you can see it put the names alphabetical, now just like in the first tutorial, we didn't put line breaks in there, and so they're all put on one line, but if we go and look at the code you can see everything is in alphabetical order here. Now to put the line breaks in, we'd have to pipe this into something else, you know, maybe a while loop or said or something of that sort, and it can get very sloppy, so I'm not even going to try here, we're just going to go into the PHP tutorial, but I just want to bring you up that you could do stuff that way, and you could get it to work, and it just can get very sloppy, like I said a lot of times I would actually have completely, I would have my PHP script that would call shell scripts, so I would have multiple different files doing random little different things, and I'm trying to get better about not doing that. So within our PHP tags here, what I'm going to do now is just like last time, I'm going to create an array, I'm going to call it lines, and then we're going to use this file function, and we are going to call our names.list, remember to end each command with a semicolon, and now last time, what we did, we said for each, and then we said our array of lines as names, so we're looking at each item, so for each, we're doing a for loop for each item within our array here, which is each line, we are going to create a variable called names, and then we are going to do something for each line, and last time, we did something like echo dollar sign names, and we gave it a line break, so we would have the line break there, and semicolon there, let's go ahead and save that real quick, and run it, there we go, they're not an alpha quarter though, because we haven't done that yet, this is basically what we did in the first tutorial. So how do we sort it, so it's in alphanumeric order, well it's actually going to be a lot simpler than you might think, we are going to say sort, we're doing a sort function here, and we're going to pass it our array of lines, and that is it, so basically we're saying, you know, let's go over the whole thing, we're going to say okay, we're going to create an array here, this array is going to look at the file called this, and basically put each line as a separate item in the array, then we're just going to use the sort function and say hey, sort everything in here, put everything in alphabetical order, and replace it with the alphabetical alphanumeric list, and then we read lines one at a time alphabetically, so if we refresh up here, you can see they are now in alphabetical order, let's make that a little bit bigger for you guys, so they're now in alphabetical order, so how do we do reverse order, well that's even harder, we have to say our sort for reverse the sort, so let's save that and refresh, and there we go, now we have the reverse order of our text file, so that is a quick look at sorting text files with PHP, once again this is number two in this series of PHP tutorials, there's quick little tips preparing us for creating full applications using jQuery, HTML, and CSS as the user side, and then occasionally we're going to use some PHP to grab information from a server, so just preparing you for that, this is going to allow us to create some applications that are very easily ported to pretty much every platform, so anything that's running a modern operating system, whether it be Mac OS, iPhone OS, Android, Linux, Windows, free BSD, any of the BSDs, and forgive me if I skipped over your operating system, but anything really this stuff is going to run on everything, because the more complex stuff is going to be done on the server side, and everything else is going to be done with basically JavaScript, HTML, and CSS, which everything is compatible with pretty much, and we're going to learn how to package those as some of the standalone applications, or through a web browser, so keep on watching, because that's what's in store once we get through some of these PHP and jQuery tutorials, so I thank you for watching, please visit FilmsByChris.com, that's Chris with a K, if you are interested you like these tutorials, if you like where I'm heading with this, then definitely not only comment, but give me a thumbs up on this video so that I know, and I hope that you have a great day.