Use the following to get the last (or only) item of a hierarchy
Code:
{#genre:'list_union('', subitems($, -1, 0), ',')'}
This says get the first item from the end (-1) to the last item (0). As before, the list_union removes duplicates. Remove it to improve performance if you don't mind dups.
Regarding the sort -- there is no way to avoid it. The subitems function sorts the result. If it did not then the order of items would be random, not the original order. And in any event, the original order of #shelf is probably semi-random, not what is displayed.
Because subitems sorts, the list_sort I used simply wasted time.
Note also that list_union can change the order of the items, although in this case it does not.