I have to sort a list based on the searched text position in the string i.e. if the searched value appears first in the string then its position should be first in the list, if it appears second in the string then it should be second but all the strings with first word as searched value should appear first in the list.
For example, input strings are:
- Chris is a good person
- Every person should be like chris
- Not every person is chris
- person like chris are good
The searched value is "person".
Output should be :
- person like chris are good
- Every person should be like chris
- Not every person is chris
- Chris is a good person
You can grab a copy of NGrams8k and analyze strings a number of ways. This will sort by the position as well as returning it.
Results:
If you change the search text to "Chris" you get:
Something else you could do with NGrams8K is sort by the number of occurrences of your search string.
Returns:
Cheers.