sorting for online-time
simplified sorting, sorting by online-time now works, pruned some replicated code
reduce some errors