View Single Post
Old 02-14-2012, 03:04 AM   #6
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,250
Karma: 821512
Join Date: Jan 2010
Location: France
Device: Many android devices
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.
chaley is offline   Reply With Quote