implement vecotr and sort for longest prefix match