Sorting the values in Map

Hi,
In my application, i want to use Mapping in the case
Key -Value
A - 2
B - 3
C - 7
D - 5
For that I used HashMap. But I want to sort the values and place in map as from Highest order. For that in google it is suggested to refer SortedMap. But this SortedMap is sorting the Key content only not Value content.
For sorting the Value's what I have to do under Collection?
Any idea?

DHURAI wrote:
I will explain my concept in detail.
I am having a String array; a[]={qw,q,as,l,kj,q,q,l}
From this i am mapping
key value
qw 1
q 3
as 1
l 2
kj 1
using HashMap.
From this I want to fetch q whose value is greater. How can I do this?
Hope this explains better.You still haven't said how often you want to do that. What I explained will work, but it might not be what you want if you often change values.

Similar Messages

  • Sort the values in Bex query variable screen

    Dear Experts,
    Is it possible to sort the values of a dropdown list for variables on BEX variable selection screen ? 
    For example, For calender month selection, the values are by default sorted by ascending order.
    Is it possible to sort by descending order ? 
    Regards,
    ravindra

    Hi Ravindra,
    yeah it is possible by writing an abap code for the field calmonth/week...etc this is depends on the F4 help of the selection field. so you need to write a code for F4 help for making it in descending order. hope it helps.
    Thanks,
    Vachan

  • Sorting the values in the HashMap maintaing the key-value relationship

    Hi,
    I want to sort the HashMap based on the values. I have tried several other ways but the closest I can get is sort the values but have to loose the keys. I wanted to sort the collection based on the values but at the same time maintain the key-value relationship. Is there any way I can get this functionality either by using any collection API or by some other way?
    Thanks and appreciate your help....
    --coolers                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I believe that Commons Collections from Jakarta has something like that.
    http://jakarta.apache.org/commons/collections/
    But I'm not sure.

  • Sorting the values of a map.

    I have been stuck on this problem for a while. I have a TreeMap, which can be changed to a HashMap if needed, with a set of keys as Strings and values which are Integers.
    EXAMPLE
    String1, 123
    String2, 333
    String3, 222
    String4, 758
    I need the values sorted in decending order (9-0).
    Thanks in advance for all your help.

    I have been stuck on this problem for a while. I have
    a TreeMap, which can be changed to a HashMap if
    needed, with a set of keys as Strings and values which
    are Integers.You must be the first one who changed a TreeMap into a HashMap and then lived to tell about it. -:)
    Anyway a TreeMap is always sorted on key, not value. To have your dataset sorted on value you must reload into another TreeMap and invert the key/value pairs in the process. The values then become keys in the new TreeMap which means that the former values must be unique for this to work.
    I'm sure there's a simple solution but it's better if you described what you want to accomplish in general terms than to let people struggle with a solution scenario that's probably suboptimal. How do you want to access your objects and why and when do you need them to be sorted.

  • Sort the payload before mapping to target

    Hi
    My Source structure is a sbelow
    <ROW>
    <ordernumber>01<ordernumber>
    <EAN>E1<EAN>
    <ROW>
    <ROW>
    <ordernumber>01<ordernumber>
    <EAN>E2<EAN>
    <ROW>
    <ROW>
    <ordernumber>01<ordernumber>
    <EAN>E3<EAN>
    <ROW>
    <ROW>
    <ordernumber>01<ordernumber>
    <EAN>E1<EAN>
    <ROW>
    My Target is as below
    <Header>
    <Ordernumber>01<ordernumber>
    <item>
            <EAN>E1<EAN>
    <item>
    <item>
            <EAN>E2<EAN>
    <item>
    <item>
            <EAN>E3<EAN>
    <item>
    <Header>
    My question how can i sort the EAN numbers in the source structures and map to the target.
    Thanks
    Srinivas

    I tested it if your source and target structure matches as I have given here then it will definitely work. try it out.
    Source Structure
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_Test_forum xmlns:ns0="http://yash.com/yh1309/EDIFile_2_EDIFile">
       <Row>
          <OrderNo>1</OrderNo>
          <EAN>A</EAN>
       </Row>
       <Row>
          <OrderNo>2</OrderNo>
          <EAN>A</EAN>
       </Row>
       <Row>
          <OrderNo>1</OrderNo>
          <EAN>B</EAN>
       </Row>
       <Row>
          <OrderNo>2</OrderNo>
          <EAN>B</EAN>
       </Row>
       <Row>
          <OrderNo>1</OrderNo>
          <EAN>C</EAN>
       </Row>
       <Row>
          <OrderNo>3</OrderNo>
          <EAN>A</EAN>
       </Row>
    </ns0:MT_Test_forum>
    Target Structure
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_Test_forum_tar xmlns:ns0="http://yash.com/yh1309/EDIFile_2_EDIFile">
       <Header>
          <OrderNo>
             <orderno>1</orderno>
             <Item>
                <EAN>A</EAN>
             </Item>
             <Item>
                <EAN>B</EAN>
             </Item>
             <Item>
                <EAN>C</EAN>
             </Item>
          </OrderNo>
          <OrderNo>
             <orderno>2</orderno>
             <Item>
                <EAN>A</EAN>
             </Item>
             <Item>
                <EAN>B</EAN>
             </Item>
          </OrderNo>
          <OrderNo>
             <orderno>3</orderno>
             <Item>
                <EAN>A</EAN>
             </Item>
          </OrderNo>
       </Header>
    </ns0:MT_Test_forum_tar>
    OrderNor -> RemoveContext -> Sort -> SplitByValue( Valuechange) ->collapseContext--> OrderNo
    OrderNo -> RemoveContext -> Sort -> SplitByValue( Valuechange) ->Item
    OrderNor -> RemoveContext -> Sort -> SplitByValue( Valuechange) ->collapseContext--> splitByValue(each value)--->orderno
    OrderNo-> RemoveContext - > SortByKey -->SplitByValue(Each Value) -> EAN
    EAN -> RemoveContext -> /
    notice that a field name orderno inside each occurence of <OrderNo> in the target structure to get the order number in that field

  • Sorting the values in a column in a Web Template Report

    Hi All,
    I have a report build on WAD in which a table is displayed with certain rows and columns and have certain text values in one column and few numeral values in the other few columns. When i right click on the 1st column(having text values) and click on Sort Ascending by Name, the values are sorted in groups.There are other 3 columns next to that column which have text values as well but when i right click on them and try to sort it in some order(ascending by name/descending by name), there are no reorganization of the values in the column. Again, once i go to the other remaining columns having numeral values in it, the values get sorted in ascending/descending order as per the sort selection. Please advise on how i can make the sort possible in the columns in which the rearrangement is not happening. Do i need to change the Query to some settings? Please advise.
    Thanks!
    Subhra Ghosh.

    Subhra,
    In BW reports, the sorting of characteristic values always happens left-to-right. When you choose to sort by columns 2 - 4, you are actually just specifying whether to sort ascending|descending and/or by key or text. This sort happens for each value of the first column, however. Therefore, the sort in column 2 is only noticeable when you have more than one row with the same value in column 1, etc.
    This sorting behavior is different than the Excel type of sorting, which may be your confusion here.
    If you want to sort first by a column other than column 1, you must swap the columns so that the desired characteristic is in column 1.
    Hope this helps...
    Bob

  • How to change the values of Map Region Column "REGION_NAME"

    Hi guys,
    To correspond with the values in my "CITY" column, I have to change the values of Region_name column in the map..
    region_name column contains the name of the territories in English
    but City column in my table contains the names of the territories in Arabic.
    To enable the link of the map, the values of both column ( CITY in my table, REGION_NAME in the map region ) should be identical.
    How can I change the values of REGION_NAME COLUMN ???
    This is the first time for me I deal with maps, and I hope my question is clear..
    Regards,
    Fateh

    Solved by using the following code
    var particulars = this.parent.COURSENAME.resolveNode("#items"); 
    this will bring the dropdown list into the variable particulars
    then
    for (var i = 1; i < particulars.nodes.length; i++)
    p = particulars.nodes.item(i);
    here p.value will have the dropdown line by line;
    add your valdiations etc

  • Custom Manage Property does not pick up the value from mapping crawl property

    Hi All,
    I have created a custom list with the column name that's called "category".
    Then I ran full crawl and I saw the "ows_category" crawl property is created.
    Then I create the manage property names as "Category" and map with the "ows_category" and run the full crawl again. (Retrivable, Searchable, Refinable options are checked)
    After full crawl, I searched Category:keyword but it returned 0 result. 
    But when I search keyword, that list item is retuned
    I tried to debug with the spsearch2013 tool and there is no "Category" manage property in the return XML.
    It seems the Manage Property does not pick up value from the crawl property. (Something might be wrong with the index schema)
    Do you have any suggestion?
    Do I need to reset the index?
    Best Regards,
    Andy

    Hi Andy,
    When you search ‘category’ in crawled properties(Central Administration->Search Service Application->Search Schema), you will see ows_Category is mapped to DiscussionCategory, like the screenshot:
    So, I suggest you create a new column using another name, then test again, compare the result.
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • How To sort the values of a OVS result table?

    Hello,
    I'm trying (because i'm new je je), to implement an OVS for an inputfield in my WD app. Now i know for sure that my sophisticated value help do the search of the object and stuff, but i'm wondering if i can "sort" or include the sort method in my result table that is show in my OVS rendered view? Plis if you guys could give me some tutorials or info that would be great
    Kisses
    MC

    ok that's another idea that i had in mind, built a new window, but my issue was how call that window fron the table cell, just like an OVS? wich UI Element help me with that, no link to action, no button, it most be something like an inputfield, how did you do that?
    Kisses
    MC

  • How to avoid round of the value in mapping

    Hi!
    I am trying to pass in mapping value 999999.999, but   XI rounds it to 1000000.
    How can I avoid this?
    I tried to change types of field in Data Type: string, float, same problem.
    Any help appreciated.

    Hi,
    try using this function in message mapping
    FormatNum     
    Converts I according to a pattern that you define using the function properties. The possible patterns are the same as in the Java class java.text.DecimalFormat.
    Regards,
    Kai

  • Sorting the Values in Dropdown box values in dashboard

    Hi,
    I have a small problem.   In the dash board I have a drop down which will displays the list of the employess.  How to assign the sort to this.  I have checked all the option but in the web application designed I didnt find any option for it.
    Please help me in this.
    Thanks
    naveen

    Yes, you can do this by specifying this parameter in your web item.
    <param name="ONLY_VALUES" value="X"/>
    This will return all the objects as part of a form so you need to write your own html form around this.
    To sort this within javascript, the easiest thing to do is convert this list of form values to an array, sort this array, and then re-render the form values. There's an example online of doing this with a table here:
    http://javascript.internet.com/forms/sort-data-table.html
    You could do this with for a form in a similar manner.

  • Sort the Valuenode records in table

    Hi Experts,
    Following is the code I wore to retrive and display Portal roles in a table. The context maintained is as follows and got the results properly. I want to know how to sort the table values by Role_Name?. Could some one help me?
    [Value node]      Role_table
    [Value Attribute] RoleID
    [Value Attribute] Role_Name
    [Value Attribute] PCD_Location
    //Retrive the roles from the Role factory          
    String[] theroles = rolefact.getRolesOfUser(unique_id,true);
    for(int i=0; i<theroles.length; i++ )
    //Retrive user attributes and add to the context attribute values     
    String roleid = rolefact.getRole(theroles<i>).getDisplayName();          
    String rolename = rolefact.getRole(theroles<i>).getDescription();
    String role_desc = rolefact.getRole(theroles<i>).getUniqueName();
    IPrivateUserView.IRole_tableElement rowelement = wdContext.createRole_tableElement();
    rowelement.setAttributeValue("RoleID",roleid);
    rowelement.setAttributeValue("Role_Name",rolename);
    rowelement.setAttributeValue("PCD_Location",role_desc);
    //Append the roles obtained and bind to the rolenode
    al.add(rowelement);
    wdContext.nodeRole_table().bind(al);
    Please help me with some code on how to sort the value node table?. I promise to award the points for the right solution. I appreciate coding help.
    Thank you
    Regards
    Maruti

    Hi Maruti,
    1. Get the size of the node, save it in a variable say <b>si</b>
    int si = wdContext.nodeRole_table().size();
    2. Iterate as follows
    for(int i=0;i<si;i++)   
         for(int j=i+1;j<si;j++)
             if(wdContext.nodeRole_table().getRole_tableElementAt(i).getAttributeAsText("Role_Name").compareToIgnoreCase(wdContext.nodeRole_table().getRole_tableElementAt(j).getAttributeAsText("Role_Name"))<0)
             wdContext.nodeRole_table().swapElements(i,j);
    Regards,
    Mathan MP

  • How to avoid the presence of element in the Destination file if the value is empty

    Hi,
    I am using a map, in which Source is an XML File, Destination is a FlatFile
    For Eg:
    Input File
    <Name>
    FirstName>aaa</FirstName>
    <LastName>bbb</LastName>
    </Name>
    Output File
    FirstName     LastName
    aaa                bbb
    Destination Schema is also the same, but if the Last name value is empty, the LastName element should not be present in the Destination Flat File.
    Eg:
    Input File
    <Name>
    FirstName>aaa</FirstName>
    <LastName></LastName>
    </Name>
    OutputFile should be
    FirstName
    aaa
    Please help in making this requirment....
    Regards, Vignesh S

    Set the “Min Occurs” property of the LastName header element in the flat-file schema to “0” (Zero)
    Create a map which maps the Schema for the XML file to the flat-file schema.
    In the map, use the Logical Existence and Value mapping as shown in the below image. Here Logical
    Existence function is used to check the existence of the field LastName in the input XML. If LastName element exist, then using the Value mapping functiod, map the Contant-LastName  (this
    would be the header). Below image shall help you with thisexplanation.
     As you can see, for the detail record, the value is mapped directly and for the header, as per you requirement a check has been made to for the existence of the LastName
    field in the XML to populate the LastName header node. If LastName is empty in the XML, header LastName would not be populated.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

  • Sort F4 values in BEX variable screen

    Hi ,
    Does anyone know how to sort F4 value help in BEX variable selection screen. This query has come up time and again in SDn and there seems to be no proper reply to this. If anyone has worked on this do let me know.
    Thanks,
    Vaishnavi

    Hi Nara,
    Kindly have a look at below thread,
    Sort the values in Bex query variable screen
    Hope this helps.
    Regards,
    Mani

  • Sorting the numbers in a Varchar2 Column

    I've a column in a table which contains two type of values, either 0-30 or A-Z. Can I sort the values of this column firstly on numbers and then on Characters like this:
    1
    2
    3
    4
    10
    A
    B

    with t as (
               select 'A' str from dual union all
               select 'B' str from dual union all
               select to_char(level) str from dual connect by level <= 10
    select  str
      from  t
      order by case
                 when translate(str,'A0123456789','A') is null then to_number(str)
               end nulls last,
               str
    STR
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    A
    STR
    B
    12 rows selected.
    SQL> SY.

Maybe you are looking for

  • Search result in CRM_KW

    Hi, we save documents on the content server from the document tab on BP. In transaction CRM_KW the documents can be search for by using attributes like keywords. The problem is that the search result in CRM_KW only presents 100 hits. Does anyone know

  • Trying to uninstall Itunes on my pc, windows vista.

    I want to install the upadates to my iphone. I can't update itunes either.  When I attempt either I get the msg: The feature you are trying to use is on a network resource that is unavailable.  Then it says to enter an alt path to a folder containing

  • Problem with VO Extension

    Hi All, I have a requirement like , I need to change the query of the lov For this ,I extended the VO to incorporate the new query, this query has some bind parameters Now I extended the CO of the Lov to set the bind parameters of the VO query, but t

  • Scan count VS logical Reads

    I have two versions of a query. 1.  Scan count 136, logical reads 2776907,CPU time = 230848 ms,  elapsed time = 55753 ms. 2. Scan count 0, logical reads 89225788, CPU time = 437696 ms,  elapsed time = 46195 ms. The only difference I can see is 2 quer

  • TS3276 How to get message when email has been received and read?

    How do I set my Mail so I can get a message when an email has been received and read?