title: Group similar records in a list by maintaining order and relevancy
body: <p>I am rephrasing the question with more clear sample data to help the members better understand my problem.</p>
  
  <p>I have used linq for fairly basic queries but have no idea how to write complex queries. I have data like this in a list,</p>
  
  <pre><code>var list = new List&lt;Users&gt;()
  { 
    new Users() { FirstName = "John", LastName= "Doe", MiddleName = "P.", Phone = "111-111-111", Email = "abc@xyz.com" },      
    new Users() { FirstName = "Alex", LastName= "Jones", MiddleName = "S", Phone = "333-333-222", Email = "xyz@abc.com" },   
    new Users() { FirstName = "John", LastName= "Doe", MiddleName = "p.", Phone = "111-111-111", Email = "abc@xyz.com" },   
    new Users() { FirstName = "John", LastName= "Doe", MiddleName = "", Phone = "111-222-111", Email = "abc@xyz.com" },   
    new Users() { FirstName = "John", LastName= "", MiddleName = "", Phone = "111-111-111", Email = "abc@xyz.com" },   
    new Users() { FirstName = "Alex", LastName= "James", MiddleName = "N", Phone = "111-111-111", Email = "cde@xyf.com" },   
    new Users() { FirstName = "Alex", LastName= "Jones", MiddleName = "S", Phone = "333-333-222", Email = "xyz@abc.com" },   
    new Users() { FirstName = "John", LastName= "Doe", MiddleName = "", Phone = "111-222-111", Email = "" }, 
  };
  </code></pre>
  
  <p>These are just sample records for a user and there are thousands of records like this. I want to sort/group the users such that for a single user (FirstName, LastName) the top most records will be those which FirstName, LastName, MiddleName, Phone and Email match. After these those records needs to come whose FirstName, LastName, MiddleName and Phone are matching. So rows with most matching columns will be on top and rows with least matching columns will be on bottom. Rows of a single user should not overlap with other users so similar user's records will be together.</p>
  
  <p>What I have tried:</p>
  
  <p>I have used the following Linq query to achieve the desired results,</p>
  
  <pre><code>obj = obj.OrderBy(x =&gt; (chkFirstName.Checked) ? x.FIRSTNAME : "")
                                 .ThenBy(x =&gt; (chkLastName.Checked) ? x.LASTNAME : "")
                                 .ThenBy(x =&gt; (chkMiddleName.Checked) ? x.MIDDLENAME : "")
                                 .ThenBy(x =&gt; (chkPhone.Checked) ? x.PHONE_PRIMARY : "")
                                 .ThenBy(x =&gt; (chkEmail.Checked) ? x.EMAIL1 : "").ToList();
  </code></pre>
  
  <p>It is not getting me the order correctly. For example this query will group most matching columns rows on top for a user then few records will be for another user. I am thinking that may be Group can do this? Kindly guide me through this.</p>
  
  <p>(Note): There are extra columns in the List which I have not mentioned but they will not be used for any sorting or grouping.</p>