Fixed sortMarkets method and unit test.