Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris Knowles 141 posts 222 karma points
    Dec 19, 2011 @ 15:17
    Chris Knowles
    0

    Sort nodes into alphabetical order c#

    Hi,

    I have a usercontrol that looks at the child items of a node for airport names, they are listed arranged as such:

    - North America
    - USA
    - Anchorange
    - Alaska
    - Baltimore

    I have produced the following code and am struggling to find the correct way or sorting these. I have looked through the forum but can't find a way that works whilst looking for a particular type of node.

        public void getAirports()
        {
            XPathNodeIterator nodeElementIterator = umbraco.library.GetXmlNodeById("1350");
            nodeElementIterator.MoveNext();
            //move to first   
            bool blnFirst = true;
            XPathNodeIterator nodeIterator = nodeElementIterator.Current.SelectDescendants("Airport", "", false);
            while (nodeIterator.MoveNext())
            {
                Document document = new Document(Convert.ToInt32(nodeIterator.Current.GetAttribute("id", "")));
                umbraco.cms.businesslogic.property.Property airportCode = document.getProperty("airportCode");
                lstDestination.Items.Add(new ListItem(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(nodeIterator.Current.GetAttribute("nodeName", "").ToLower()) + " (" + airportCode.Value.ToString() + ")", nodeIterator.Current.GetAttribute("id", "")));
                if (blnFirst)
                {
                    lstDestination.Items.FindByText(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(nodeIterator.Current.GetAttribute("nodeName", "").ToLower()) + " (" + airportCode.Value.ToString() + ")").Selected = true;
                    blnFirst = false;
                }
            }
        }

    I am trying to get all the airports from across all continents / countries in to an alphabetical list to display. Can someone help me do this please?

    Thanks

    Chris

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies