8. Why do we need to sort the list


#1

I have a question...Why do we need to sort the list, since we're selecting a random number anyway? Also, HOW does .php sort a list of names/text?


Functions Part 1 - Exercise 8
#2

We don't need to, as you say, we are just picking a random number so it doesn't matter. I might guess that the instructor just want us to have some practice sorting.

Strings will sort alphabetically, sort of. Here is a table of characters sorted by their ASCII codes. A is 65 and a is 97 so a word starting with A will be sorted before a word starting with a.

Do you see how that would work now?


#3

That makes sense...I guess I just had a little trouble "echo"ing the sorted array that had values PUSHED to it. I believe it needed to know what type of "glue" to use before it created an output list?

Thank you for your help!


#4

.PHP really sort a list of names/text, just try it in editor) It's sort by the alphabet.