How to sort linq result by most similarity/equality?

You want OrderBy OrderByDescending result = InstrumentsList. . Where(...) .

OrderByDescending(instrument => StringSimilarityScore(instrument. Name, searchString)) . Take(30) As to the definition of StringSimilarityScore -- a full-on fuzzy match would be best, but you could start by quantifying the match based on the proportion of the name matched by the search string: double StringSimilarityScore(string name, string searchString) { if (name.

Contains(searchString)) { return (double)searchString. Length / (double)name. Length; } return 0; } You might then want to consider the position of the search string within the name (earlier is better), for the cases where a single letter is specified -- but I'll leave that up to you.

:-).

You want OrderBy / OrderByDescending -- result = InstrumentsList. . Where(...) .

OrderByDescending(instrument => StringSimilarityScore(instrument. Name, searchString)) . Take(30); As to the definition of StringSimilarityScore -- a full-on fuzzy match would be best, but you could start by quantifying the match based on the proportion of the name matched by the search string: double StringSimilarityScore(string name, string searchString) { if (name.

Contains(searchString)) { return (double)searchString. Length / (double)name. Length; } return 0; } You might then want to consider the position of the search string within the name (earlier is better), for the cases where a single letter is specified -- but I'll leave that up to you.

:-).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions