Sort a string by custom order | Meta Interview Question