How to get the ContractId of contracts that are stored in a list

Note that your comparator returns results that will confuse the sorter:

    if offer1.value < offer2.value then LT
    else if offer1.value < offer2.value then GT

This means that your comparator declares that there exist values o1, o2: Offer, such that (c1, o1) < (c2, o2) and (c2, o2) < (c1, o1).

I suggest using compare directly, instead; use

    compare offer1.value offer2.value

and you can skip all the if/else boilerplate.

(By the way, you can use the ``` lines to demarcate code samples; example over here.)

1 Like