Bkr Knk

Bkr Knk

  • NA
  • 19
  • 2.9k

c# orderby wrong ordering

Apr 1 2018 6:17 AM
  1. foreach (var item in items.SearchQuery(textBox1.Text, 1))    
  2.       {
  3.                 Video video = new Video();
  4.                 video.Url = item.Url;    
  5.                 list.Add(video);    
  6.                            using (var client = new WebClient())    
  7.                 {    
  8.                     var html = client.DownloadString(video.Url);
  9.                     // HtmlAgilityPack class    
  10.                     var htmlDoc = new HtmlAgilityPack.HtmlDocument(); 
  11.                     htmlDoc.LoadHtml(html); 
  12.                     var htmlElement = htmlDoc.DocumentNode.Element("meta"); 
  13.                     HtmlNode mdnode = 
  14.       htmlDoc.DocumentNode.SelectSingleNode("//meta[@name='keywords']"); 
  15.                         var htmlAtribute = mdnode.Attributes["content"]; 
  16.                         string fulldescription = htmlAtribute.Value;    
  17.                         byte[] bytes = Encoding.Default.GetBytes(fulldescription);    
  18.                         fulldescription = Encoding.UTF8.GetString(bytes);    
  19.                         string text = fulldescription; 
  20.                     Collection<string> collection = new Collection<string>();    
  21.                     string[] bits = text.Split(','); 
  22.                     foreach (string rr in bits)    
  23.                     {    
  24.                         collection.Add(rr); 
  25.                     } 
  26.                         var sortedElements = from rr in collection    
  27.                                              orderby rr.Length descending    
  28.                                              select rr;    
  29.                     foreach (string c in sortedElements)    
  30.                     { 
  31.                         listbox1.Items.Add(c);
  32.                     }    
  33.                 } 
  34.             }    
  35. }  
The Output :( As you can see , it is ordering part by part, but i want full order which should includes all items in the listbox
 
 

Answers (2)