Persistent sorted maps and sets with log-time rank queries