Sort by Count Occurrences of a Word in list rows linq
===

my question was how to sort list by the occurrence of word in every row of linq data....i got answer from here by someone. that is giving right output. here is the code

    void Main()
    {
	List<SearchResult> list = new List<SearchResult>() { 
			new SearchResult(){ID=1,Title="Geo Prism GEO 1995 GEO* - ABS #16213899"},
			new SearchResult(){ID=2,Title="Excavator JCB - ECU P/N: 728/35700"},
			new SearchResult(){ID=3,Title="Geo Prism GEO 1995 - ABS #16213899"},
			new SearchResult(){ID=4,Title="JCB Excavator JCB- ECU P/N: 728/35700"},
			new SearchResult(){ID=5,Title="Geo Prism GEO,GEO 1995 - ABS #16213899 GEO"},
			new SearchResult(){ID=6,Title="dog"},
		};

		var to_search = new[] { "Geo", "JCB" };

	var result = from searchResult in list
			 let key_string = to_search.FirstOrDefault(ts =>  searchResult.Title.ToLower().Contains(ts.ToLower()))
			 group searchResult by key_string into Group
			 orderby Group.Count() descending
			 select Group;
			 result.ToList().Dump();



     }
    // Define other methods and classes here
    public class SearchResult
    {
		public int ID { get; set; }
		public string Title { get; set; }
    }

i am getting the output like

    ID Title 
    -- ------
    1  Geo Prism GEO 1995 GEO* - ABS #16213899 
    3  Geo Prism GEO 1995 - ABS #16213899 
    5  Geo Prism GEO,GEO 1995 - ABS #16213899 GEO 
    2  Excavator JCB - ECU P/N: 728/35700 
    4  JCB Excavator JCB- ECU P/N: 728/35700 
    6  dog 
 
the above output is ok. all rows having the ord GEO comes first because it found maximum time in most of the rows means GEO the word found in 3 rows and JCB found in two rows so JCB related rows comes next.

i need another sort after getting the above output on whole data....that is that GEO rows comes first
which row has the GEO word maximum time...so my output would look like below

    ID Title 
    -- ------
    5  Geo Prism GEO,GEO 1995 - ABS #16213899 GEO 
    1  Geo Prism GEO 1995 GEO* - ABS #16213899 
    3  Geo Prism GEO 1995 - ABS #16213899 
    4  JCB Excavator JCB- ECU P/N: 728/35700 
    2  Excavator JCB - ECU P/N: 728/35700 
    6  dog 

i found a linq query which Count Occurrences of a Word in string
here is the code
-------------------

    string text = @"Historically, the world of data and data the world of objects data" ;
    string searchTerm = "data";
    //Convert the string into an array of words
    string[] source = text.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' },   StringSplitOptions.RemoveEmptyEntries);
    var matchQuery = from word in source
                 where word.ToLowerInvariant() == searchTerm.ToLowerInvariant()
                 select word;
    int wordCount = matchQuery.Count();

i got it from this url
http://msdn.microsoft.com/en-us/library/bb546166.aspx

so tell me how could i use the above code to sort my title. how could use second sort for Count the Occurrences of a Word in title field as a result my output would look like

    ID Title 
    -- ------
    5  Geo Prism GEO,GEO 1995 - ABS #16213899 GEO 
    1  Geo Prism GEO 1995 GEO* - ABS #16213899 
    3  Geo Prism GEO 1995 - ABS #16213899 
    4  JCB Excavator JCB- ECU P/N: 728/35700 
    2  Excavator JCB - ECU P/N: 728/35700 
    6  dog 


