sorting and fix anchor targets