bugfixes in sort algorithm

sort the market events on top. Bugfix in events with no ending time