Ronnie O'Sullivan equalled Stephen Hendry's record of reaching 19 World Championship quarter-finals with a hard-fought 13-10 win over Ding Junhui.