Sorting the Message Array

Hi
Does anyone know whats the best way to sort an array of Message[] after getting this array from the Folder.
Sorting by date is straight forward (ie sort by msg #, ascending / descending).
How about sorting by FROM, SUBJECT or SIZe (in each case ascending/descendin)?
Any idea would be much appreciated
many thanx

You could sort "by hand" using e.g. the simple bubble-sort but might also want to
have a look at collections (java.util.Collection and the like) above version 1.2.

Similar Messages

  • Can I sort the message for JavaMail??

    Can I sort the message for JavaMail??
    sort by From or sort by Subject or sort by Date and so on...
    thanks~~

    Get all the message objects via their headers, don't call getContent
    unless you want to download the whole message. You can get their message
    id's and their header contents such as subjects, from etc in one go,
    next to no time...
    With message id, subject, from etc...
    You can sort by subject and with the new array, the first message id
    in the array might be the 20th item on the server

  • How to sort the messages in Browser Console by time

    In the Browser Console the messages are sometimes out of order. This can be confusing when debugging an application. Is there an easy way to sort the messages by the timestamps?
    See also: https://bugzilla.mozilla.org/show_bug.cgi?id=854435.
    It seems this has been the case for some time. I am seeing it in version 26.0. I can copy the messages to a spreadsheet and sort them there, but that's a bit tedious.

    Thanks cor-el. I notice this in the interleaving of Net and Logging messages. I haven't yet noticed a case where Net or Logging messages alone are out of order. Separate threads with different latency to posting messages makes sense.
    From my perspective, hiding the timestamps isn't a solution. It obscures the problem rather than fixing it. I noticed the problem before I looked at the timestamps carefully. When I'm debugging, the order of events is sometimes essential to a correct understanding of what is happening. So, I hope that in addition to giving people the option to hide the timestamps, an option to sort the messages by timestamp will be added. If it were my choice, sorted by timestamp would be the default.

  • I need sorting VI that returns the sorted array element's positions in the unsorted array

    I need a VI that will very quickly (n log n) sort a 1D array of doubles.  This VI should not only output the sorted array, but for each of the sorted array elements, it should also output that sorted array element's position in the unsorted array.  So for example if the input array were:
    unsorted_array
    4.1
    2.3
    7.0
    5.6
    10.2
    Then the output arrays would be:
    sorted_array
    2.3
    4.1
    5.6
    7.0
    10.2
    indices_array
    1 (the value 2.3 is located at position 1 in the unsorted_array)
    0 (the value 4.1 is located at position 0 in the unsorted_array)
    3 (the value 5.6 is located at position 3 in the unsorted_array)
    2 (the value 7.0 is located at position 2 in the unsorted_array)
    4 (the value 10.2 is located at position 4 in the unsorted_array)
    This way I could generate the sorted_array using just the indices_array and the unsorted_array.  Has anyone written a nifty piece of code to do this?  I did some research on (n log n) sorting algorithms but most of them use recursion which I don't know how to do in LabVIEW.  It would also be nice to have an algorithm like this that could sort an array of strings.
    cheers,
    Richard

    Try something like the attached example (LabVIEW 7.0). I think it does what you need.
    (To understand the code, it is important to know that arrays of clusters are sorted by the first element in the cluster).
    Sort array itself sorts also array of strings, so you could just substitute, keeping the rest of the code the same.
    Sort array uses a variation of quicksort, so it should have about NlogN complexity.
    (If you think you only need the array of indices to later generate the sorted array, it does not make much sense to even do it. To get the indices, you need to sort the array anyway. You should just sort the plain array directly.
    Message Edited by altenbach on 07-13-2005 03:47 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SortAndIndex.vi ‏26 KB

  • Newbie trying to sort 2D string array

    Dear all,
    After read some book chapters, web sites including this, I still don't get the point.
    If I have a file like,
    1 aaa 213 0.9
    3 cbb 514 0.1
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    and I load into memory as a String[][]
    here comes the problem, I sort by column 1 (aaa,...,bba) using an adaptation of the Quicksort algorithm for 2D arrays
    * Sort for a 2D String array
    * @param a an String 2D array
    * @param column column to be sort
    public static void sort(String[][] a, int column) throws Exception {
    QuickSort(a, 0, a.length - 1, column);
    /** Sort elements using QuickSort algorithm
    static void QuickSort(String[][] a, int lo0, int hi0, int column) throws Exception {
    int lo = lo0;
    int hi = hi0;
    int mid;
    String mitad;
    if ( hi0 > lo0) {
    /* Arbitrarily establishing partition element as the midpoint of
    * the array.
    mid = ( lo0 + hi0 ) / 2 ;
    mitad = a[mid][column];
    // loop through the array until indices cross
    while( lo <= hi ) {
    /* find the first element that is greater than or equal to
    * the partition element starting from the left Index.
    while( ( lo < hi0 ) && ( a[lo][column].compareTo(mitad)<0))
    ++lo;
    /* find an element that is smaller than or equal to
    * the partition element starting from the right Index.
    while( ( hi > lo0 ) && ( a[hi][column].compareTo(mitad)>0))
    --hi;
    // if the indexes have not crossed, swap
    if( lo <= hi )
    swap(a, lo, hi);
    ++lo;
    --hi;
    /* If the right index has not reached the left side of array
    * must now sort the left partition.
    if( lo0 < hi )
    QuickSort( a, lo0, hi, column );
    /* If the left index has not reached the right side of array
    * must now sort the right partition.
    if( lo < hi0 )
    QuickSort( a, lo, hi0, column );
    * swap 2D String column
    private static void swap(String[][] array, int k1, int k2){
    String[] temp = array[k1];
    array[k1] = array[k2];
    array[k2] = temp;
    ----- end of the code --------
    if I call this from the main module like this
    import MyUtil.*;
    public class kaka
    public static void main(String[] args) throws Exception
    String[][]a = MyUtil.fileToArray("array.txt");
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,1);
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,3);
    MyMatrix.printf(a);
    for the first sorting I get
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bba 111 7.1
    9 bbc 417 10.4
    3 cbb 514 0.1
    8 dee 887 2.1
    (lexicographic)
    but for the second one (column 3) I get
    3 cbb 514 0.1
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    this is not the order I want to apply to this sorting, I would like to create my own one. but or I can't or I don't know how to use a comparator on this case.
    I don't know if I am rediscovering the wheel with my (Sort String[][], but I think that has be an easy way to sort arrays of arrays better than this one.
    I've been trying to understand the Question of the week 106 (http://developer.java.sun.com/developer/qow/archive/106/) that sounds similar, and perfect for my case. But I don't know how to pass my arrays values to the class Fred().
    Any help will be deeply appreciated
    Thanks for your help and your attention
    Pedro

    public class StringArrayComparator implements Comparator {
      int sortColumn = 0;
      public int setSortColumn(c) { sortColumn = c; }
      public int compareTo(Object o1, Object o2) {
        if (o1 == null && o2 == null)
          return 0;
        if (o1 == null)
          return -1;
        if (o2 == null)
          return 1;
        String[] s1 = (String[])o1;
        String[] s2 = (String[])o2;
        // I assume the elements at position sortColumn is
        // not null nor out of bounds.
        return s1[sortColumn].compareTo(s2[sortColumn]);
    // Then you can use this to sort the 2D array:
    Comparator comparator = new StringArrayComparator();
    comparator.setSortColumn(0); // sort by first column
    String[][] array = ...
    Arrays.sort(array, comparator);I haven't tested the code, so there might be some compiler errors, or an error in the logic.

  • Sort and Object array of Arrays

    Hi,
    I have an object array that contains a String[] and an int[].
    Object[String[], int[]]
    The values in the Strings array must be in the same position in the array as those in the int array i.e
    String [0] is the string representation of int[0].
    Its for a bar chart.
    That is all working beautifully.
    Now however I want to sort the int array in descending order by the value of the ints in the array and thus the order or the String array has to mirror this.
    I am using a comparator to do this but it just wont work. I'm sure this is the way but how should it look?
    Has anybody got any ideas?
    Thanks in advance,
    L.

    use the bubblesort:
        for (int i = a.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (a[j][1] > a[j+1][1]) {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
        }

  • What types of sort performed by sort method of Array class ?

    I use normal bubble sort and method Array.sort() to sort some given data of an Array and then count the time.But Array.sort() method takes more time then normal bubble sort.
    Can anybody tell me what types of sort performed by sort method of Array class?

    I'm pretty sure that in eariler versions (1.2, 1.3
    maybe?) List.sort's docs said it used quicksort. Or I
    might be on crack.You are actually both correct, and wrong :)
    From the documentation of the sort methods hasn't changed in 1.2 -> 1.4 (as far as I can notice), and the documentation for sort(Object[]) says (taken from JDK 1.2 docs):
    "This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
    The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance, and can approach linear performance on nearly sorted lists."
    So, how could you be correct? The documentation for e.g. sort(int[]) (and all other primities) says:
    "Sorts the specified array of ints into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance."
    Your memory serves you well :)
    /Kaj

  • Mail (8.2) message sorting in Yosemite: No longer allows quick tab sorting of messages?

    In previous versions of Mail, you've always been able to do quick sorting of messages with the To/From, Subject, Date Received tabs at the top of the message lists. I don't use the Conversation view, preferring instead the Classic view. When selecting/highlighting a message in a list, the message would resort themselves if you clicked on any of the header tabs. However, now, this doesn't happen. It will resort the whole list and you lose your target message.
    Note, that searching for messages or the "show related messages" function in the View pull-down menu is far less useful and convenient to scan messages. There's no more list.
    Does anyone have any insights into how to get this feature back? Or why such a simple and useful feature would no longer be present.

    Frontage,
    YES.  Isn't it silly.  Somehow, software companies feel an over arching need to offer new versions & so often, THEY MESS THEM UP!  If only we could easily go back to the previous ones.
    However, in this case, there is a solution-  Like you, I was trying to figure out what Old Toad was saying & where on the screen his pic came from.  I was clicking around the upper left corner of the screen, on the flag icon, on the mailboxes & perhaps other things.  Something I did restored the feature, so that when sorted, the message used as the sort key remains selected.  I quit Mail & restarted & it still works.
    So there is a solution.  (I just wish I could say what it was.)

  • I have downloaded and installed the latest version of numbers on my mac. Everytime I save and then try to reopen that document, I receive a message telling me that I need a new version of numbers. Also, when I try to sort the date column, it sorts out of

    I have downloaded and installed the latest version of numbers on my mac. Everytime I save and then try to reopen that document, I receive a message telling me that I need a new version of numbers. Also, when I try to sort the date column, it sorts out of order. The last version sorted fine.

    Welcome to Apple Support Communities
    When you install the new iWork version, the old iWork version is kept, so it looks like you are opening your old version.
    To fix this, open a Finder window, choose Applications in the sidebar and drag the new Numbers version to the Dock, so you can access to it quickly. Open all documents from this version. I don't recommend you to delete the old Numbers version in case you need it.
    Respecting to the second question, you will get better answers in the Numbers for OS X forum

  • How do i sort out error r6034 on my windows vista when i try to start itunes, the message box is from microsoft visual c++runtime library, it says an application has made an attempt to load the C runtime library incorrectly,

    how do i sort out error r6034 on my windows vista when i try to start itunes ???
    the message box is from microsoft visual c++runtime library, it says an application has made an attempt to load the C runtime library incorrectly, P;ease contact the application's support team for more information.

    Hey deepakmenonfrompune,
    Thanks for the question. I understand that you are experiencing issues with iTunes for Windows. The following article outlines the error message you are receiving and a potential resolution:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Some Windows customers may experience installation issues while trying to install or open iTunes 11.1.4.
    Symptoms may include:
    "The program can't start because MSVCR80.dll is missing from your computer"
    "iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows Error 126)”
    "Runtime Error: R6034 - An application has made an attempt to load the C runtime library incorrectly"
    "Entry point not found: videoTracks@QTMovie@@QBE?AV?$Vector@V?$RefPtr@VQTTrack@@@***@@$0A@VCrashOnOverf low@@***@@XZ could not be located in the dynamic link library C:\Program Files(x86)\Common Files\Apple\Apple Application Support\WebKit.dll”
    Resolution
    Follow these steps to resolve the issue:
    Check for .dll files
    1. Go to C:\Program Files (x86)\iTunes and C:\Program Files\iTunes and look for .dll files.
    2. If you find QTMovie.DLL, or any other .dll files, move them to the desktop.
    3. Reboot your computer.
    Note: Depending on your operating system, you may only have one of the listed paths.
    Uninstall and reinstall iTunes
    1. Uninstall iTunes and all of its related components.
    2. Reboot your computer. If you can't uninstall a piece of Apple software, try using theMicrosoft Program Install and Uninstall Utility.
    3. Re-download and reinstall iTunes 11.1.4.
    Thanks,
    Matt M.

  • The message ~There was a problem connecting to the server "your-447023ae6b".appears when I try to play music transferred from my PC to my iMac. Files were transferred from my PC by a Genius. How do I sort it? Next appointment with genius is 5 days away!

    The message ~There was a problem connecting to the server “your-447023ae6b”.appears when I try to play music transferred from my PC to my iMac. Files were transferred from my PC by a Genius. How do I sort it? Next appointment with genius is 5 days away!

    Hi
    Thanks this has helped me solve the problem.
    I used the Outlook Anywhere connectivity tester you suggested. Selected Outlook autodiscover.
    It told me that it could not resolve things on any of the 4 tests.
    I saw that using the last test "Attempting to contact the Autodiscover service using the DNS SRV redirect method", was the only one likely to work in my case.
    I had already changed 3 entries in dns to point at my DDNS address but this had not worked, from the errors I could see that it was just the certificate name not matching so I changed the DNS entries for Autodiscover, autoconfig and _autodiscover._tcp
    to be webmail.domain.com which is a CNAME to my ddns address for the broadband router, which in turn forwards ports 80 and 443 to the exchange server for owa and activesync access. I got an error message saying that I had an illegal entry in my SRV record
    as a CNAME is not allowed, but it saved the change anyway.
    I reran the test and it worked.I can now make new outlook clients attach teo exchange.
    Thank you, after 8 hours yesterday of trying to reolve this I suddnely got it to work on one laptop but the other still would not and had lost track of what I could have changed so had no idea what actually made it work.
    Thank you for your suggestion.

  • I need to sort the incoming file contents before message mapping

    Hi All,
      I have requirement like i have to sort the file contents before message mapping in Xi. is there any option please suggest me with your value information.i dont want to sort in message mapping before that i want file contents to be sorted order.waiting for your quick reply.
    Thanks,
    seshagiri

    Hi,
    You can do this in one scenario.
    Lets say you have MT_Source and MT_Target as two message types.
    Now your MM1 will be between MT_Source & MT_Source, that is same message type. Here you built your sorting logic.
    Now create MM2, between MT_Source & MT_Target. Here your actual mapping logic will be implemented. The input payload for MM2 will be sorted data.
    Now in operation mapping, first call MM1 and then call MM2 (You have a plus + sign to add multiple mapping programs). Due to this sequence, at run time first MM1 will be executed and after that its oupt will be given to MM2 as source payload.
    Hope its clear. Plz let me know if you have any doubts.
    -Gouri

  • I have Photoshop Elements 7.0 and when I go to sort the photos in order (from oldest date) I keep getting the message "Photoshop Elements 7.0 has stopped working" and then the program closes.  Sometimes, eventually it has sorted as I request but today thi

    I have Photoshop Elements 7.0 and when I go to sort the photos in order (from oldest date) I keep getting the message "Photoshop Elements 7.0 has stopped working" and then the program closes.  Sometimes, eventually it has sorted as I request but today this has been rejected over 15 times.  What is wrong?

    Try the licensing service update:
    http://helpx.adobe.com/creative-suite/kb/error-licensing-stopped-windows.html
    EDIT I see that maybe you did (is that the patch you mean? ); if so, try the other suggestions there.

  • About the sort method of arrays

    Hi,
    I found that for primitive types such as int, float, etc., algorithm for sort is a tuned quicksort. However the algorithm for sorting an object array is a modified merge sort according to the java API. What is the purpose of using two different sorting strategy?
    Thanks.

    The language knows how to compare two ints, two doubles, etc. For Object arrays, however, it's not a simple matter of comparing two reference values as ints or longs. We're not comparing the references. We have to compare the objects, according to the class's compareTo() method (if it implements Comparable) or a provided Comparator. The size of an int is known, fixed, and small. The size of an object is unknown, variable, and essentially unbounded. I don't know for sure that that difference is what drove the different approaches, but it is a significant difference, and mergesort is better suited to use cases where we can't fit the entire array into memory at one time. It seems reasonable that we'd get better locality of reference (fewer cache misses, less need to page) with an array of ints than with an array of objects.
    Edited by: jverd on Mar 18, 2011 3:16 AM

  • Need to sort an object array using an element in the object.

    hi all,
    i need to sort an object array using an element in the object.can someone throw some light on this.
    Edited by: rageeth on Jun 14, 2008 2:32 AM

    [http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html]

Maybe you are looking for

  • Remote not working on dvr but works on other boxes

    I have a Dvr box in the back of the house, It was working fine today earlier. I went back in the room and poof the remote dosent work on the box. It still works the tv. So I took it out to the other boxes in the house and it works fine on the other b

  • Flash Volume in Director

    Hi, I have a number of flash files in .swf format that I need to incorporate into a Director Movie. I would like the user to be able to adjust the voume of them through Director but cannot find a way to adjust the volume of flash files through Lingo.

  • How to charge my Itouch with laptop

    hi peoples, just bought the iTouch today, naughty piece of kit. but i know when you get it....it needs a good 12 or so hours charge....am i right....? if so i have a laptop and cant really leave that on with it charging as i dont have a mains charger

  • Nokia 2330 Classic - no USB port

    Hi, I noted that the above phone does not have a USB port. The user manual for it does not show a USB port but the page on the support web site lists the Nokia Suite Software which shows a USB port! I note that it is possible to use Blue tooth! Just

  • If my ipad needs to be replaced by apple what paper work will I need?

    My Ipad3 is toast. I have been speaking with Apple and have tried resetting and even restored and still not working.  What paper work will I need to get a replacement?  My Ipad is still under warranty.