fix transaction data sorting

no more lines going in the wrong direction
optimize sorting during new data insert