Have a try to see if this trick works in a listbox as well? I haven’t tried it but i would guess it works. (I’m also guessing you are creative enough to implement it with a sorting algorithm)
https://forum.renoise.com/t/sorting-my-sub-menu/39044
EDIT: woops… this answer might have been too advanced. But this is how I would try modifying the dBatchProcess script.