my website is about poetry. 

I use a custom field for each poem where the meta key is "Author" and the meta value the author's name, e.g. "Allison, James". 

Now I'd like my posts to show up in the loop in a certain order: alphabetically according to the meta value mentioned above (e.g., all poems by "Allison, James"; then all poems by "Barnes, John"; then all poems by "Carter, Sue" and so on). 

The poems of one specific author (= meta value) should then be ordered alphabetically by title (e.g. Allison, James: "After dark", "Before sunset" and so on). Is there a way to do this? I've found the string below, but it wouldn't work (perhaps I put it in the wrong place or I have to add some code somewhere else in addition to make it work).

Do you have an idea what piece of code I have to put in which php-file to get the desired effect?

```
<?php
 $querystr = "
    SELECT wposts.* 
    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id 
    AND wpostmeta.meta_key = 'Autor' 
    AND wposts.post_type = 'post' 
    ORDER BY wpostmeta.meta_value ASC
 ";

 $pageposts = $wpdb->get_results($querystr, OBJECT);

 ?>

```

Thanks a lot! Cheers, Felix