Fix sort keys like "a.0.b". Fixes #2439.