initial sorting