added name sorting function