I have an array of string that I would like to have sorted based on the portion of the word. For instance, if I gave “comp” as the search word, it would sort the array in a descending order which starts with “comp”, such as “compare”, “composition”, “computer” etc. Rest of the words that do not match is either left alone or sorted in an alphabetical order (whichever is easier).
Having that said, what is the algorithm that I can use to solve this problem?
This will select words you need and sort only those words: