Sort Xml list

Hello,
I am trying to learn actionscript 3 for work and have a very
specific project I need it for. I have been searching every
available tutorial have bought a few books to read but I cannot
find out how to do a few simple things.
The main thing I need to do right now is sort an xml list by
the date of an event before I start picking which nodes to display.
(<dt_event_start>) I need the function to be able to sort by
date or by alpha for a different xml list I will be sorting later,
not both at the same time, just one or the other. My code is sparse
right now, all it does is pick events in a certain city and write
them all in one big list to a text box on screen. Later I will have
to separate out each part to make a header for each event and
choose which nodes to display, so i need to sort the xml list
before I start displaying the nodes in separate text boxes within a
larger container repeated with a loop through the list.
included is one xml entry and the as3 code i have so far
Any help would be greatly appreciated and then I can go
looking for the other code I need.

This thread was "imported" from the old forums -- most, if not all, code seems to have disappeared. But here are the sort functions I posted:
function sortXML(source:XML, elementName:Object, fieldName:Object,
options:Object = null):XML
     // list of elements we're going to sort
     var list:XMLList=source.elements("*").(name()==elementName);
     // list of elements not included in the sort -
     // we place these back into the source node at the end
     var excludeList:XMLList=source.elements("*").(name()!=elementName);
     list= sortXMLList(list,fieldName,options);
     list += excludeList;
     source.setChildren(list);
     return source;
function sortXMLList(list:XMLList, fieldName:Object, options:Object =
null):XMLList
     var arr:Array = new Array();
     var ch:XML;
     for each(ch in list)
           arr.push(ch);
     var resultArr:Array = fieldName==null ?
           options==null ? arr.sort() :arr.sort(options)
           : arr.sortOn(fieldName, options);
     var result:XMLList = new XMLList();
     for(var i:int=0; i<resultArr.length; i++)
           result += resultArr[i];
     return result;

Similar Messages

  • Open a SharePoint List item in Modal Pop up in SP 2013 fails after you filter or sort the list

    Sorry for the long post. This has been killing me. I had this script working perfectly fine in SharePoint 2010 (online) and basically i have a source custom list (list A) with a hyperlink column and a Destination List with say title and my name.
    Source List (list A) looks like this with these 2 columns
    Title    Test Link
    A         Link 1
    B         Link 2 
    C         Link 3
    Each of these links link to the actual list item in the destination list, so for example, link 1 is/sites/2013DevSite/Lists/Destination%20List/EditForm.aspx?ID=1
    So basically i want anytime the Link are clicked that point to another list's item to open in a modal dialog and the script below worked perfectly fine in SharePoint 2010 (online)
    <script language="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
    <script language ="javascript" type="text/javascript">   
    jQuery(document).ready(function() {
    jQuery('a[href*="EditForm.aspx"]').each(function (i, e) {
    // Store the A tag's current href in a variable
    var currentHref = jQuery(e).attr('href');
    jQuery(e).attr({
    'href': 'javascript:void(0);', 
    // Use the stored href as argument for the ShowInModal functions parameter.
    'onclick': 'ShowInModal("' + currentHref + '");'
    function ShowInModal(href) {
    SP.UI.ModalDialog.showModalDialog({title: "Edit Item", url: href});    
    </script>
    All it does is find the href tags for that particular value Editform.aspx and the pop modal works in SP 2010 online. So the site page is designed in such a way there is a content editor web part with the reference to this javascript file and the sharepoint
    list is right beneath it and this worked perfectly opening in modal windows in SP 2010.
    Since migration to 2013, this is what exactly happens
    1.) when you come to the site page, the modal works,
    2.) If you filter or sort on say the Title or Test Link column in Source list (lets say you select the Value A), the script does not fire at all, if i hover over the hyperlink, the who hyperlink is shown and does not open the hyperlink in the modal pop up.
    - This is important because i want to be able to sort on a particular item...
    Could someone please let me know what am i doing wrong and why is this not working when i sort the list. Thanks for all the help.
    Once again i am trying to open a sharepoint list item in Sharepoint 2013 from another list using Jquery

    A ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
    http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
    There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
    http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
    Regards.

  • Help with using mergesort to sort a list of names alphabetically?

    Hi, I'm trying to sort a list of names alphabetically, case-insensitive by using the mergesort technique.
    I wrote this code and when I trace it through on paper with an example array of names, it should work, but when I run it with an actual txt file, it's not correctly alphabetical.
    I'd appreciate it if someone could take a look at my code and give me some ideas on what my problem might be.
    Thanks in advance! (note: I also posted this question to java-forums.org, as I've been working on this little problem for over five hours and am in desperate need of some help!)
    public static void mergeSort(String[] names) 
            if (names.length >= 2) 
                String[] left = new String[names.length/2]; 
                String[] right = new String[names.length-names.length/2]; 
                for (int i = 0; i < left.length; i++) 
                    left[i] = names;
    for (int i = 0; i < right.length; i++)
    right[i] = names[i + names.length/2];
    mergeSort(left);
    mergeSort(right);
    merge(names, left, right);
    // pre : result is empty; list1 is sorted; list2 is sorted
    // post: result contains result of merging sorted lists;
    // add merge method below
    public static void merge(String[] names, String[] left, String[] right)
    int i1 = 0;
    int i2 = 0;
    for (int i = 0; i < names.length; i++)
    if (i2 >= right.length || (i1 < left.length && left[i1].compareToIgnoreCase(right[i1])<0))
    names[i] = left[i1];
    i1++;
    } else
    names[i] = right[i2];
    i2++;

    Welcome to the forum.
    Please read this to learn hot to format your code (and other things relevant for this forum):
    https://forums.oracle.com/forums/ann.jspa?annID=1535
    923566 wrote:
    Hi, I'm trying to sort a list of names alphabetically, case-insensitive by using the mergesort technique.
    I wrote this codeDo you know the <tt>TreeSet</tt> class?
    http://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html
    With that sorting Strings is a two liner:
    http://www.java2s.com/Code/Java/Collections-Data-Structure/TreeSetDemo.htm
    bye
    TPD

  • Project 2013 - How do you sort the list of Enterprise Templates in Project Pro?

    In Project Pro 2013, click File > New > Enterprise I see the list of templates from our project server. We have a global installation with 40-50 templates. These are displayed in a random order and reading through the whole list to find the one I
    want is quite tedious. Is there a way to sort this list alphabetically? Can the list be displayed as a "details" view rather than icons?

    Greg --
    Guillaume is totally correct.  The display order of enterprise templates is by the date they were created.  I have tested this on a Project Server 2013 system that has the latest Cumulative Updates applied.  The problem is that in the
    Microsoft Project 2013 desktop application, Microsoft has ditched the Templates dialog we used to see and replaced it with a page in the Backstage.  I am afraid that in doing so, they have eliminated the sorting capabilities that we found in earlier versions.
    Out of curiosity, I have sent an e-mail to my MPV contacts within the Microsoft Project Server development team at Microsoft, asking if there is any intention of changing this functionality to allow for sorting by template name.  If I get an answer,
    I will post it in this user forum.
    Your question is a good one, and the sorting problem (or lack of sorting) can be a real problem in any organization that has a sizable number of enterprise templates.  Hope this additional bit helps.
    Dale A. Howard [MVP]

  • Sorting a List on Parent Child Relationship

    I have to sort a list on Parent Child relation
    say
    I have a following list
    Object(Id,ParentId,.........)
    obj1(1,1,........);
    obj2(2,1,........);
    obj3(3,3,........);
    obj4(4,1,........);
    obj5(5,3,........);
    obj6(6,1,........);
    obj7(7,3,........);
    obj8(8,4,........);
    Logic is such that
    If Id and Parent Id is same then It is Parent Record
    I want the Result like
    obj1(1,1,........);
    obj2(2,1,........);
    obj4(4,1,........);
    obj6(6,1,........);
    obj3(3,3,........);
    obj5(5,3,........);
    obj7(7,3,........);
    obj8(8,4,........);
    Suggect Some Logic...............
    Thanks in advance.............

    sAsho wrote:
    That's the question how to do that?????????????????????????One question mark is sufficient. If you're going to go out of your way to write like an idiot, people won't take you seriously.
    "How do I do that?" is way to broad a question. You need to do some research, take your best shot, and post a specific question about the specific parts that are giving you trouble.
    Suggest something. I did suggest something.
    I suggested what you should google for to get you started. Just like writing clearly and intelligently, if you can't be bothered to read what people suggest and put in the effort to follow that suggestion and do your own research, you'll find people will quickly lose interest in trying to help you.
    Now I am additionally suggesting that you 1) pay closer attention and 2) do your own research.
    Recurcive sort kind of a think.................No idea what you're saying here. See my first point in this reply.

  • Sorting the list of value like in BEX but out of crystal report

    All,
    I have created a crystal report base on a BEX query where I have a variable for which  i am filtering base on a field period.fiscalyear.
    for the list of values that prompt you for this variable ...
    l in BEX we can do the sort by either alphabetical ascending order or descending alphabetical order such as:
    here is for ascending
    001.2008
    001.2009
    or by clicking on it we can do the following: (descending)
    012.2009
    012.2009
    however in crystal when refreshing the report in infoview it sorts the list of value base on the month
    something like this :
    JAN 2008 [0FISCPER].[K42008001]
    FEB 2008 [0FISCPER].[K42008002]
    We would like to have in crystal the same behaviour than in BEX,  so in crystal we would like to be able to get the list of values sorted in either ascending order to descending order. is there a way to do so ?
    notes also that we would like to avoid to create the variable in crystal
    Philippe

    Hi,
    in Crystal Reports you have per InfoObject - depending on the definition - the key value, the description and the member unique name. In BW these objects are defined as NUMC in most cases - which means it is a character / string.
    In your example the value is 001.2008 and 001.2009. What you can do in Crystal Reports is to split up the values into year and month and then sort based on the actual numbers.
    Ingo

  • Show only the most recent event in XML list based on date

    Hello,
    I'm working with Spry and an XML list of events for my site.
    Displaying the full list of events isn't a problem. However, I'd like to display only the next upcoming event, based on the date.
    For instance, today is April 27th. I'd like to be able to display only the next upcoming event which happens to be on May 3rd. Then once that date passes, the next upcoming event is shown (May 17th).
    Can anyone give me a hand?
    Thanks!

    This seems like it's on the right path. Thank you for your response, though, I'm afraid I need a bit more help.
    I can get the statement to work, but I'm having trouble trying to figure out how to use the results. I can run the IF statement, and it checks the first value in the XML list. Since the first item in the list is older than the date I input, it just returns "false". I'm not really sure how I can make it return just the first entry that is "true".
    Secondly, I'm not sure how to get it to use the "Current Date" without manually entering the date in the if statement. Is there an easy way I can get the system date for it to check with?
    Thanks!!

  • Is it possible to sort the list of Conditions/Calculations?

    Is it possible to sort the list of Conditions/Calculations so that they display alphabetically in the list?
    My list of conditions is getting quite long and haphazard now!
    Cheers
    Sapphie

    I was afraid of that!. It is very disappointing because , as I am developing a set of reports for the first time, I will create conditions/calculations in quite a non-ordered way and then end up wanting to group similar ones together.
    Hopefully a future version will allow this?
    Lee

  • In Apple Color Picker, need to sort custom list

    I just created a custom color list in Apple's Color Picker which is not sorted and I want it to be.
    FYI: the Apple Color Picker opens in many applications for choosing what color something should be. For example, in TextEdit use menu Format > Font > Show Colors.
    On the Color Picker, the 3rd tab by default has pre-defined lists of colors, including "Apple", "Developer", and "Web Safe Colors". I created a custom color list, which is out of order alphabetically (or any other way). I would like to sort that list alphabetically (or by color, I guess) without deleting and recreating every color. Can this be done?

    Hi, whytwolf.
    I thought your question was interesting, so I spent some time experimenting.
    The Colors Palette doesn't permit re-ordering the items in the list, such as by dragging or Command-dragging them.
    Unfortunately, the color list one creates using the Colors Palette — e.g. the file colorlistname.clr in your Home > Library > Colors directory — is an NSDictionary object. It's saved in binary format and it appears virtually impossible to edit reliably with a text editor. These objects are usually created and read using Cocoa programming. I know of no editor specifically designed to permit one to change these objects directly, and a variety of Web searches for such an editor failed to find a tool.
    It appears there was once a utility called Color List Editor that seemed tailor-made for your purpose, but it appears to have vanished without a trace. While the VersionTracker listing remains, all of the links to the download are broken. I was able to track down the author's Web site but the download isn't available there. I've e-mailed him in case it's still available, though it may not work with Tiger given its age. If I hear back anything from the author, I'll let you know.
    What I recommend you do is recreate the list, first focusing on the order of items by name you want to include in such. Then, once that's sorted, assign the swatches. You should probably do a trial run on paper or using a spreadsheet to get the names and sequence correct before you undertake the actual list-creation process again using the Color Palette. Then work carefully, since correcting errors in mid-list means deleting the error and all entries thereafter. Most tedious!
    It might also be worthwhile to submit a Mac OS X Feedback, suggesting Apple enhance the Color Palette so that one can reorder colors by dragging them in the list, at least for color lists the user has created, i.e. those on which the user has Access permissions of Read & Write.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • How can i sort a list ?

    Hallo!
    Some days ago, i made a small programm, which is able to read *.txt files and list it out! Now i am trying to sort this list ( by age or name). I think it�s possible with the "compareTo" Methode. But i don�t no how? Please give me some tips!
    Thanks a lot!
    chris!

    I suggest you try to look at java.util.Comparator interface.

  • Is there a way to sort subscriber list by Surname?

    Is there a way to sort subscriber list by Surname?
    Currenty it is sorted by Full name, sorting by first name alphabetically.I would prefer it to sort by surname.

    Hi,
    Not within the system unfortunately.  The workaround is to export the report and manually separate the full names into first and last name columns to achieve what you are after. 
    This is currently on our wishlist to enhance in the future. 
    Kind regards,
    -Sidney

  • Query on sorting  XML using XSLT and getting the same XML as output !

    Hi,
    Looking for one information regarding sorting XML using XSLT , with the sorted XML as output. For eg. my XML is :
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="sort1.xsl"?>
    <levelone>
         <child ID="1" sort="5">
              <name>Paul</name>
         </child>
         <child ID="2" sort="1">
              <name>Adam</name>
         </child>
         <child ID="3" sort="2">
              <name>Will</name>
         </child>
    </levelone>
    and XSL :
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/levelone">
         <xsl:copy>
         <xsl:apply-templates>
              <xsl:sort select="@sort"/>
         </xsl:apply-templates>
              </xsl:copy>
         </xsl:template>
         <xsl:template match="child">
              <xsl:copy-of select="."/>
         </xsl:template>
    </xsl:stylesheet>
    This does the sort based on Name. But I want to get the same xml as output with the name sorted. Eg.
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="sort1.xsl"?>
    <levelone>
         <child ID="2" sort="1">
              <name>Adam</name>
         </child>
         <child ID="1" sort="5">
              <name>Paul</name>
         </child>
         <child ID="3" sort="2">
              <name>Will</name>
         </child>
    </levelone>
    Any pointers will be highly appreciated.
    - Thanks

    Don't you want <xsl:sort select="name"/> rather than <xsl:sort select="@sort"/>?

  • SQL Developer 1.5.1 - Sorting Table / List of Columns - Why So Slow

    Hi All,
    why is it so slow to sort the list of columns names in a table.
    It appears to be going back and querying the database again. - shouldn't it just be doing a local sort of the JTable ?
    Thanks
    Bill
    Edited by: wfs on Oct 28, 2008 2:31 PM

    Yes, it does query again - as it does with everything else being sorted.
    You're right they could implement local sorting on a little, complete set, but that should be requested at the announced SQL Developer Exchange, since I recon that would get pretty tedious (taking in count NLS sorting settings).
    Then mind you have to query again anyway if a result set is not complete (by default, fetches are 50 records at a time), or fetch everything before being able to apply the local sort, which will give you even more problems on large tables.
    Regards,
    K.

  • Sort picking list by storage bin or material in customizing

    Hello Gurus,
         How can I sort picking list by storage bin or material in customizing?
    thanks very much!

    It's done at IMG - Logistics Execution -  Warehouse Management - Strategies - Define Sort Sequence for Stock Removal (Picking)

  • LINQ sorting on List Object - Various Object Type

    I try to sort a List<Object> where the Object are different classes but all share the same Property Name for instance.
    I got a Base Class where Class A and Class B inherit from the Base Class.
    So during the Linq query I cannot specify with object type this is.
    Problem here "from ?????Entry_Global?????? list in Entries"
    Thanks for helping.
    ////Entries is a List<Object> which consist of class object as following\\\\\
    public abstract class EntryBase<T>
    private string _Name;
    public string Name
    get { return this._Name; }
    set { this.SetProperty(ref this._Name, value); }
    public class Entry_Global : EntryBase<Entry_Global>
    public class Entry_CC : EntryBase<Entry_CC>
    private string _url; //Web url
    public string Url
    get { return this._url; }
    set { this.SetProperty(ref this._url, value.Contains("http") ? value : "http://" + value); }
    public List<Object> SortBy()
    IEnumerable<KeyedList<string, object>> groupedEntryList = null;
    //The proble reside in the fact that list is not only one type
    //so when comes in the orderby "Name" it doesn't know Name
    //or any other properties which are all common to all those class
    //It does not want to convert Entry_CC or Entry_Global to EntryBase
    groupedEntryList =
    from ?????Entry_Global?????? list in Entries
    orderby list.Name
    orderby list.CategoryRef.Name
    group list by list.CategoryRef.Name into listByGroup
    select new KeyedList<string, object>(listByGroup);
    return groupedEntryList.ToList<object>();

    Entry_Global and Entry_CC don't share the same base class since EntryBase<Entry_Global> and EntryBase<Entry_CC> are two totally different types so you cannot cast the objects in the List<object> to a common base class in this case.
    You could cast from object to dynamic though:
    public List<Object> SortBy()
    List<object> objects = new List<object>();
    objects.Add(new Entry_Global { Name = "K" });
    objects.Add(new Entry_CC { Name = "A" });
    objects.Add(new Entry_Global { Name = "I" });
    objects.Add(new Entry_CC { Name = "C" });
    var sortedObjectsByName = (from o in objects
    let t = (dynamic)o
    orderby t.Name
    select o).ToList();
    return sortedObjectsByName;
    The dynamic keyword makes a type bypass static type checking at compile-time:
    https://msdn.microsoft.com/en-us/library/dd264736.aspx. This basically means that a dynamic type is considered to have any property of any name at compile time. Of course you will get an exception at runtime if the type doesn't have a Name property but
    providied that all objects in the List<T> to be sorted are of type EntryBase<T> you will be safe as long as the EntryBase<T> type defines the Name property that you sort by.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

Maybe you are looking for