Custom state for a list

Hello!

I have a list of things (items). Each item has buyers and sellers (who can buy or sell it, respectively). The number of buyers varies (when a new purchase is made).
I want to show a repeating group, and sort it by a custom state number. The number has to be calculated dividing number of buyers by number of sellers (I need to show first the best percentages).

But I can’t calculate that percentage for each item of the repeating group. How can I ?

image