major overhaul, add support for tie-breaking by timestamp, reversed sort options, etc.