The magic trick is that the last line in the code block is the return value.
when you pass a function that takes a single argument (in this case just the $_) to sort, it will call your function for every element in the input array and use the result of that function to sort the elements by. The "// 0" is there in every field because if the input line doesn't have the expected format, you'll get a bunch of warnings, because the variables will contain undefined values, you can try it for yourself with inputs like "anaconda", "beetle", "zebra". The last part of the puzzle is how sort will sort lists of lists (because it has now replaced every string with a list of the parts we've supplied); By default, sort uses the earliest entry in the list that is different, so it's very much like lexicographic sort. Does that explain everything? - Timo