tweaked name sorting function