This is a simpler solution, if you want a total control over the code and don’t want to use a query.
$authors = get_users('role=author');
if(isset($authors) && !empty($authors))
{
echo "<ul>";
foreach($authors as $author)
{
$posts = get_posts(array('author'=>$author->ID));
//if this author has posts, then include his name in the list otherwise don't
if(isset($posts) && !empty($posts))
{
echo "<li>".$author->user_nicename."</li>";
echo "<ul>";
foreach($posts as $post)
{
echo "<li>".$post->post_title."</li>";
}
echo "</ul>";
}
}
echo "</ul>";
}
?>
You can also use this in your filter function.