Comparator and treemap

Hi
I have treemap of integer as key and list as value which is giving results
(2,email)
(1,dfg)
(4,dfgh).
But I have to show result in descending order sorted by key of integer
like (4,dfgh)
2,email
1,dfg
how to do it.comparator used but not worked

Hi Rashmi,
what ever the code sample posted by you is working for me. please check this
public class TreeMapSorting
     public static void main(String[] args)
          TreeMap<Integer,Object > ab1= new TreeMap<Integer,Object>();
          ab1.put(5, "sometext5");
          ab1.put(3, "sometext3");
          ab1.put(4, "sometext4");
          ab1.put(2, "sometext2");
          TreeMap<Integer,Object > tm2= new TreeMap<Integer,Object>(new Decreasin());
          tm2.putAll(ab1);
          System.out.println(tm2);
class Decreasin implements Comparator<Integer>{
     public int compare(Integer i2,Integer i1){
     return i1.compareTo(i2);
}Edited by: sri06 on Aug 12, 2008 7:28 AM

Similar Messages

  • How can I compare and delete duplicate files?

    I have nearly two terabytes of images stored in my image archives and I'm sure that there are many duplicates.  Is there an easy way to compare and delete duplicate files to save space on my drives?
    Thanks,
    Tom

    Hi Tom,
    The's no "easy" way, even if they're the same size, name, etc., they can be different qualities or even contents, so they really have to be compaed byte by byte, but...
    https://itunes.apple.com/us/app/photosweeper-lite-get-rid/id506150103?mt=12

  • Date fields and compare and get the later date of the fields

    I am trying to compare these date fields and compare and get the later date of the fields
    Tables are
    TABCASER
    TABCASER1
    EVCASERS
    Field
    Are
    TABCASER1.CASER_no
    The dates are to be compared and then get the records with the highest or latest date value.
    TABCASER1.CASERRECIEVEDDATE
    EVCASERS.FINALEVDATES
    EVCASERS.PUBLICATIONDATE
    EVCASERS.PUBLICATIONDATE
    TABCASER.COMPAREACCEPDATE
    I have this code but I am trying to figure out what it all means.
    I have several questions.
    1.
    1.     greatest it is used here to compare right? How do I then output this ? do I store it to a var (coldfusion) ultimately , I wish to send it to a page of records
    2.     is it necessary to use todate? And to_date? What does this do?
    3.     decode, is this necessary too. What does this do? NULL?
    4.     
    5.     
    6.     when I do get the query results how do I send it to coldsuion and out put to a display.
    Someone sent me this code.
    is there abetter way of doing this? To compare the dates and store in a var to display. thanks
    Here is my code below:
    Greatest(
         CASE
              WHEN INSTR(TABCASER1.CASER_no,'-CE') > 0 THEN
         decode(TABCASER1.CASERRECIEVEDDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),TABCASER1.CASERRECIEVEDDATE)
                             WHEN INSTR(TABCASER1.CASER_no,'-ERNIE') > 0 THEN
         decode(EVCASERS.FINALEVDATES,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),EVCASERS.FINALEVDATES)
                             WHEN INSTR(TABCASER1.CASER_no,'-MONIE') > 0 THEN
         decode(EVCASERS.PUBLICATIONDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),EVCASERS.PUBLICATIONDATE)
                             WHEN INSTR(TABCASER1.CASER_no,'-NADINE') > 0 THEN
         decode(EVCASERS.PUBLICATIONDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),EVCASERS.PUBLICATIONDATE)
                             ELSE
         decode(TABCASER.COMPAREACCEPDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),TABCASER.COMPAREACCEPDATE)
                        END
              ,decode(TABCASER.COMPAREACCEPDATE,NULL,TO_DATE('01/01/1900','mm/dd/yyyy'),TABCASER.COMPAREACCEPDATE))
              between TO_DATE('#dateformat(form.startDate,"mm/dd/yyyy")#','MM/DD/YYYY') and TO_DATE('#dateformat(form.endDate,"mm/dd/yyyy")#','MM/DD/YYYY')
    is there abetter way of doing this? To compare the dates and store in a var to display. thanks

    Hi
    If you have date datatypes than:
    select
    greatest(TABCASER1.CASERRECIEVEDDATE, EVCASERS.FINALEVDATES, EVCASERS.PUBLICATIONDATE, EVCASERS.PUBLICATIONDATE, TABCASER.COMPAREACCEPDATE)
    from TABCASER, TABCASER1, EVCASERS
    where ...-- join and other conditions
    1. greatest is good enough
    2. to_date creates date dataype from string with the format of format string ('mm/dd/yyyy')
    3. decode(a, b, c, d) is a function: if a = b than return c else d. NULL means that there is no data in the cell of the table.
    6. to format the date for display use to_char function with format modell as in the to_date function.
    Ott Karesz
    http://www.trendo-kft.hu

  • Comparing and Combining 2 Excel Sheets

    Hi there,
    I have Microsoft Office 2008 (also Office 2007 on Windows - Using Parallel). Is there a software out there for Mac or PC where I can compare and combine two excel sheets? Each excel sheet has at least 12,000 rows. One column on each spreadsheet has a unique header.
    Anything that would be compatible with Leopard or XP that anyone would recommend.
    Thanks!
    Gilbert

    Apple Discussions doesn't have support for third-party products. Excel is a Microsoft product. You would be better off posting this question in the Excel for Mac forums at Microsoft. You can find them via Mactopia.

  • MultiThreaded compare and swap question.

    I'v got this assignment and I'm not sure which approach to take. I think I've got it right with my second try, but I was wondering if I could get some sort of verification or something.
    "Use Java monitors to implement the atomic Compare-And-Swap instruction, which has the following effect: CSW(a,b,c): < if (a==c) { c = b; return(0);} else {a = c; return 1;} > (In most concurrency books and papers instructions within angle brackets < > means that everything within the brackets is done in one uninterruptible, atomic action.) "
    Is this right?
    public synchronized int compareAndSwap(Object a, Object b, Object c)
            if ( a.equals( c ) )
                c = b;
                return 0;
            a = c;
            return 1;
        }Or is this?
    public int compareAndSwap(Object a, Object b, Object c)
            synchronized ( a )
                synchronized ( b )
                    synchronized ( c )
                        if ( a.equals( c ) )
                            c = b;
                            return 0;
                        a = c;
                        return 1;
        }Or am I totally off base? I think the latter is right as it prevents the objects themselves from being messed with.

    As far as making it an atomic action, you do that
    with synchronized, BUT more detail might be needed
    about the context in which it's supposed to be atomic
    to know what to sync on.OK, thanks. I was thinking I was crazy or something, but his question is just unclear. I have no idea what he wants and I'm not sure he does either.
    Thanks.

  • Compare and adjust functionality for Solution Directory

    Hello all,
    I am trying to use the Compare and Adjust function with a Solution Directory. There is a previous discussion about how to do this between a Master Template and Implementation Project. Now that the Solution Directory exists, I would like to do the same thing. I.e. take scenarios from the Solution Directory into individual projects to extend them before putting them back into production. Together with the check in/out function, I would like to use the Compare and Adjust (SA_PROJECT_UPGRADE) function to identify differences periodically. The button for this appears in the transaction SOLMAN_DIRECTORY, but I can't seem to activate it - i.e. it is faded out. For projects, you must first run SA_PROJECT_UPGRADE to activate this button. However, you cannot select a Solution when running the project upgrade transaction. Does anyone know how to do this? Is anyone using the Solution Directory in a similar way and have advice?
    Regards,
    Marcel

    Hi Marcel,
    Funnily enough I have the exact same question.
    Is there a way to compare changes between a maintenance project (business scenarios checked out this project) and the solution. This way the person approving the check in can see the changes before approving.
    Have you had further information on this?
    Referring back to your question, ideally once you've checked out a business scenario to a maintenance project you wouldn't continue to maintain it. It is the responsibility of that project to maintain it. In the meanwhile if you have a support issue that requires that business scenario to be updated, this will have to assessed and handled by either the project or the solution administrators.
    Cheers
    Ganesh

  • Compare and adjust business processes to a solution directory

    Dear all,
    I'm having truble with viewing changes that I have made in my maintenance project, using the compare and adjust function. Can you please tell me what I'm doing wrong?
    These are the steps I took:
    1. I chose a solution using transaction SOLUTION_MANAGER.
    2. I have made the solution settings, including creating a maintenance project, and enabling the check out/ check in & history functions. 
    3. Added business scenarios to the solution directory (some I chose from a project, and some I have created manualy).
    4. Checked the Scenarios out to the maintenance project.
    5. Made some changes in the maintenance project, including adding documents and transactions (transaction SOLAR01).
    6. Changed my user-specific settings to comparison mode - "display changes made in original".
    7. Checked the edited business scenarions back into the solution directory. I have checked, and the changes I've made in the maintenance project apeared now in the solution directory.
    Now starts the trouble...:
    8. I checked the scenarios out again from the solution directory to the maintenance project.
    9. Went to transaction SOLAR_PROJECT_ADMIN, marked the maintenance project line, and did "compare and adjust" of a "new version of original" .
    10. Went back to SOLAR01 and try to view the changes I have made in the maintenance project. I CAHNGES I'VE MADE ARE NOT MARKED...
    Sorry for the long description. Can you please help?
    Thank you,
    Adi

    Adi,
    Did you find a resolution to this problem? we are faced with the exact type scenario.

  • Whats the difference between comparable and comparator?

    whats the difference between comparable and comparator?
    when must i use comparable, and when must i use comparator?

    whats the difference between comparable and
    comparator?Comparable is from the java.lang package, Comparator from java.util.
    when must i use comparable, and when must i use
    comparator?Here's a tutorial on both:
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html

  • Upgrade projects and Compare and ajust func.???

    Hi All.
    I am trying setting up a demo of the benefits using SolMan for upgrade projects with Compare and Adjust functionality.
    I am following a guide with the following steps:
    1. Create an Implementation project with some processes from BPR (Using SAP R/3 Enterprise 4.7 as logical component).
    2. Model (change) the processes to simulate that a not fully SAP std. process is used at this compagny.
    3. Copy the implementation project to an Upgrade Project (with option "Adjust target project to original of the source project".
    4. Adding logical component SAP R/3 ECC 6.0 to the system landscape.
    5. Executing transaction SA_PROJECT_UPGRADE for the Upgrade project.
    Now, when I go to the project, I see no marking of changes anywhere...
    Could this be because I am using the wrong processes in my Implementation project from BPR?
    Does anyone have a good example of processes that can be good to demo this?
    Thanks in advance!
    /Per

    Hi All.
    I am trying setting up a demo of the benefits using SolMan for upgrade projects with Compare and Adjust functionality.
    I am following a guide with the following steps:
    1. Create an Implementation project with some processes from BPR (Using SAP R/3 Enterprise 4.7 as logical component).
    2. Model (change) the processes to simulate that a not fully SAP std. process is used at this compagny.
    3. Copy the implementation project to an Upgrade Project (with option "Adjust target project to original of the source project".
    4. Adding logical component SAP R/3 ECC 6.0 to the system landscape.
    5. Executing transaction SA_PROJECT_UPGRADE for the Upgrade project.
    Now, when I go to the project, I see no marking of changes anywhere...
    Could this be because I am using the wrong processes in my Implementation project from BPR?
    Does anyone have a good example of processes that can be good to demo this?
    Thanks in advance!
    /Per

  • Comparable and comparator interface in java

    Hi All,
    How comparable and comparator interface works in java and when to use comparable and when to use comparator.please give me some example(code) as I am not able to understand the difference.
    Thanks
    Sumit
    Edited by: sumit7nov on May 17, 2009 4:45 AM

    Thanks,one more doubt.
    We have Collections.sort() method and we can sort any list by this method without implementing comparable or comparator interface.Then my question is when we need to implement comparable or comparator interface or when do we write our own compareTo() or compare() methods.
    Thanks
    Sumit

  • Automate Compare and Adjust functionality

    Hello Experts,
    I would like to know if there is an easy way to automate the entire process of "compare and adjust" in template management. I mean not only the transaction SA_PROJECT_UPGRADE execution but also all the adjustments in the roll-out projects (yellow flags): I do not want to click on every process / tab where the yellow flag appears and click on the button "compare and adjust", but click just once and my roll-out project is updated...
    Thanks a lot !
    Victoria

    Hello VIctoria,
    You are not the first one to ask this question.
    Please have a look at this link. The last comment is from Andreas Diebold and he is a developer with SAP, so he is authoratative in this regards.
    Accept all changes after SA_PROJECT_UPGRADE
    To summarize: there is no way to do this presently.
    Hope this puts this issue to rest for the time being.
    Regards,
    Paul

  • Compare and merge pdfs

    How do I compare and merge pdfs?

    Document - Compare Documents to compare.
    File - Combine - Merge Files into a Single PDF to merge.

  • Need to put a logic in FDM where by accounts and ICP is compared and accord

    Hello ,
    Need to put a logic in FDM where by accounts and ICP is compared and accordingly ICP field is modified. Need to create an array of accounts
    Scenario:
    ICP needs to be derived based on account code. If account code is part of a predetermined list then further logic needs to be executed.
    For ex. If Acc is part of the account list ("7880","7881","7882","7883","7340","7341",
    "7342","7343","7345","7347","7346","8460","8603","8484","8610","8611","8612","8614")
    then if ICP <> 00000 then ICP = strfield
    else if Acc not part of list then ICP = "00000".
    We are facing issues in defining and referencing an array in FDM which would store the list of accounts code which can then be compared along with ICP. The other logic is as follows
    If strField <> "00000" And Val = Acc_Arr(i) Then
    T3 = strfield
    End If
    If strField = "00000" And Val = Acc_Arr(i) Then
    T3 = "ICPENT"
    End If
    If strField <> "00000" And Val <> Acc_Arr(i) Then
    T3 = "00000"
    End If
    If strField = "00000" And Val <> Acc_Arr(i) Then
    T3 = "00000"
    End If
    Regards,

    Hi,
    Two options:
    1. You can evaluate ICP based on either source account or target account. Use varValues(13) for source account and varValues(14) for target account in the conditional mapping statement for ICP.
    2. A faster performing option is to concatenate the Account and ICP into a single code, which you then import in the ICP dimentsion. You can then use simple mapping rules to do your ICP mappings and avoid conditional statements altogether.
    Regards,
    Vlado

  • Problems analizing compares and swaps in my algorithims

    What I need to do is analize my sorting algorthims, in terms of the number of compares and swaps. I have about 6 different sorts in one class, a couple of them came from help by, other posters, on this board. And I have a simple file reader in another class that reads a txt file, sorts, then prints, but also prints the numbers of compares, swaps, using varibles from my sorting class.
    The txt file has 64 strings(names of people). Some of the sort I get what seems to me correct, or least close to correct results, but for a couple I"m getting downright strange results. I'm trying to figure out where to put the counting variables so I can get decent results.
    In my quicksort, the results I'm getting is 1 compares 1 swaps, now obviously that's wrong but I'm trying to figure out where to put, the variables to get the correct results.
         public static void quicksort(List data, int first, int last){
                           int lower = first + 1, upper = last;
                           swap(data,first,(first+last)/2);
                           Comparable Bound = (Comparable)data.get(first);
                           while (lower <= upper){
                                while ((((Comparable)data.get(lower)).compareTo(Bound)) < 0)
                                          lower++;
                                while (Bound.compareTo(data.get(upper)) < 0)
                                     upper--;
                                if (lower < upper)
                                     swap(data,lower++,upper--);
                                else lower++;
                           swap(data,upper,first);
                           if (first < upper-1)
                                quicksort(data,first,upper-1);
                           if (upper+1 < last)
                                quicksort(data,upper+1,last);
          public static void quicksort(List data){
                           if (data.size() < 2)
                                return;
                           int max = 0;
                           //find largest data and put at end of data
                           for (int i = 1; i < data.size(); i ++)
                                if (((((Comparable) 
                           data.get(max)).compareTo(data.get(i))) < 0))
                                     max = i;
                           compares++;       // <----------------------- COMPARE
                           swap(data,data.size()-1,max);
                           swaps++;                 //    <--------------------------   SWAP
                           quicksort(data,0,data.size()-2);
    }      The selection sort results give me exactly the same for both compares, and swaps 2016.
    public static void selectionSort (List data)
               int i,j, least;
               final int size = data.size();
               for (i = 0; i < size - 1; i++)
                  for (j = i+1, least = i; j < size; j++)
                       compares++;             //   <-------------------- COMPARE
                 if (((((Comparable) (data.get(j))).compareTo(data.get(least)))) < 0)
                      least = j;
                      swap(data,least,i);
                      swaps++;                         //   <------------------------ SWAP
            Thanks for your help.

    jkc532 wrote:
    .. Is the fact that the CachedJarFile class doesn't attempt to reload the resource when it can't retrieve it from MemoryCache a bug? From your comprehensive investigation and report, it seems so to me.
    ..I've dug as deep as I can on this and I'm at wits end, does anybody have any ideas?Just after read the summary I was tired, so I have some understanding of the effort you have already invested in this (the 'wits' you have already spent). I think you should raise a bug report and seek Oracle's response.

  • Comparing and Asjusting data b/w two systems using SCU0 Transaction

    I need to compare and adjust data between two systems for tables T006 , T006A  . I am using Transaction SCU0 for comparison . It is giving me comparison results  , but  coz of some reason Button for adjusting data is not active for me .
    If I do the same thing using SM30 ,  Adjust button is coming after comparison  . I don't have maintinance views available for these tables otherwise i would have used SM30 . I want to do that using SCU0 only . Any idea how can I make  Adjust button active  .
    Regards

    Hi,
    Welcome to SDN !!!
    I would suggest you to please contact your BASIS Team. They will Activate the button for you.
    Thanks,
    Chidanand

Maybe you are looking for

  • How do I go frame to frame after a few seconds?

    Hello, I'm new here so forgive any mistakes or lack of knowledge. (Brief history: I have programmed in Pascal before, currently learning Java and Flash) So my question is i want to be able to move from frame to frame after X amount of seconds. I have

  • Restoring aperture library from an external hard drive?

    I have a major issue with my aperture library. It crashed completely and it turns out that the back up I have on my time machine was corrupted because of a hard disk error. I found this out after buying a new mac and while trying to migrate the old l

  • How to install and configure a new printer

    What are the steps to install and configure a network printer HP Laserjet 4000 to use as standard printer for printing reports. Currently I use default noprint printer.

  • Daily Logging Report

    Oracle Apps 11i Database : 9i can i get users logging report to a specific responsibility / apps on daily basis i have this query can anyone correct if i am wrong or is there any other way - select b.user_id,user_name, a.description,first_connect, la

  • Start routine code for deleting records in different language

    Hello, can someone please specify the exact code to be used in start routine, and whre exactly it needs to be pasted? this code is needed for master data notifaction type which is loaded for both languages German and English. german records are to be