As soon as all going through all trades in the block has been finalized, the median of these prices is calculated. This is done by accumulating prices and ordering them by price. After that, the trade in the middle of the ordered set is selected. Its price represents the median of the set.