Getting /last/ track in loop group

How can I get $loop(%album%%discnumber%,1) to give the last rather than first track in the loop group?

E.g. inverting %album%%discnumber%??

I am trying to export only the top track on each disc.

Thanks.