无法按字母顺序列表打印数组

I want to show some tags on my page, These are prefixed with authors-, publisher- foreg : author-authorname, publisher-publishername etc.

Also, show those tags in alphabetic order list like

A:
Amiley
Amina
B:
Bruno
Browni

I write a code but the main issues is: - My last element repeated again and again , i don't know why.. Here is my code that i write in file

    public static function author_tags(){
     $product_tags = get_terms( 'product_tag');
     array_splice($product_tags, 0, 1);
     $author_tag = array();
     $output = "";
     $previous = null;
     foreach($product_tags as $list){
     $chk = substr($list->slug, 0, 6);
      if($chk == 'author'){
       $first_letter = ucfirst(substr($list->name,7,1));
       $tag_url = "http://example.com/product-tag/".$list->slug;
       $output = "<li class='list-tags'><a href='".$tag_url."'>".substr($list->name,7)."</a></li>";
      }
     if($previous != $first_letter){
      echo "<h1><a href=''>".$first_letter."</a></h1>";
      }
     $previous = $first_letter;
     echo $output;
     } 
    }

Output:

A:
Amiley
Amina
B:
Bruno
Browni
-----------
----------
Y:
Yaomi
Yaomi
Yaomi
Yaomi
Yaomi