none
c# orderby wrong ordering RRS feed

  • Question

  • using (var client = new WebClient())
                    {
                        var html = client.DownloadString(video.Url);
    
                        // HtmlAgilityPack class
                        var htmlDoc = new HtmlAgilityPack.HtmlDocument();
    
                        htmlDoc.LoadHtml(html);
    
                        var htmlElement = htmlDoc.DocumentNode.Element("meta");
    
                        HtmlNode mdnode = htmlDoc.DocumentNode.SelectSingleNode("//meta[@name='keywords']");
    
                       
                            var htmlAtribute = mdnode.Attributes["content"];
    
                            string fulldescription = htmlAtribute.Value;
                            byte[] bytes = Encoding.Default.GetBytes(fulldescription);
                            fulldescription = Encoding.UTF8.GetString(bytes);
                            string text = fulldescription;
    
    
                        Collection<string> collection = new Collection<string>();
                        string[] bits = text.Split(',');
    
                        foreach (string rr in bits)
                        {
                            collection.Add(rr);
    
                        }
    
                         
                            var sortedElements = from rr in collection
                                                 orderby rr.Length descending
                                                 select rr;
                        foreach (string c in sortedElements)
                        {
    
    
                            listbox1.Items.Add(c);
    
    
    
                        }
                    }
    
                }

    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 

    Saturday, March 31, 2018 8:03 AM

All replies