fixed bug in sorting of contracts