2
Assuming your array is already sorted as the example:
for ($i = 0; $i < count($array); $i++) {
$parts = explode("---", $array[$i]);
$author = $parts[0];
$book = $parts[1];
$letter = substr($author, 0, 1);
if (!isset($last_author) || $last_author != $author) {
...