How to implement Three Level Sort ?

I am performing a complex search and get a List of Object. Now, the problem is I have to sort this list in three levels. That is,
If I have Object like this
public class A {
private String id ; // unique for every record
private String attr1;
private String attr2;
private String attr3;
private String attr4;
then I have to Sort the List of above type of objects
First level -attr1 as Asc
Second level -attr2 as Asc
third level - attr3 as desc
Could u suggest some way to implement this.

I would suggest using the built in Collections framework for sorting.
have class A implement the Comparable interface then implement the compareTo method as follows:
public int compareTo(Object o) {
    A a = (A)o;  // <-- may cause ClassCastException if (o instanceof A) != true, but that should not be a problem.
    int value = attr1.compareTo(a.attr1);
    if (value != 0) return value;
    value = attr2.compareTo(a.attr2);
    if (value != 0) return value;
    value = a.attr3.compareTo(attr3);  //Notice I switched a.attr3 and attr3 for desc
    return value;
}That should do it for you.
Now put everything into an instance of java.util.List and pass that to java.util.Collections.sort(java.util.List);
If you didn't create class A, and therefore can't add a method to it, then implement a Comparator. The idea is the same, just look at the java.util.Comparator API and use java.util.Collection.sort(java.util.List, java.util.Comparator) method to sort;

Similar Messages

  • I want to implement three level Horizental navigation on the top navigation and menu items are created based on the data available in a SharePoint List.

    Hi All,
    I want to implement three level Horizental navigation on the top navigation and menu items are created based on the data available in a SharePoint List.
    Implement this requirement through customization, how can i start any help
    Thanks

    Hello,
    You can follow these links to get the result that you want. You can get the desired result either using the custom list or a site map. Please make sure when you edit the master page, dont work on the original v4.master. Always make a a copy and then work
    on it.
    This link will show you how get that navigation using a list.
    http://www.bitsofsharepoint.com/BlogPoint/Lists/Posts/Post.aspx?ID=60
    This link will show you how get that navigation using a sitemap.
    http://www.sharepointdiary.com/2012/01/custom-top-navigation-using-sitemap.html
    Please mark as "Answered" if this helped you.
    Thanks,
    norasampang

  • How to Implement N-Level Approval for Bid,Live Auction,PO,Contract ?

    Hi Experts,
                  I am new to SRM 5.0. My requirement is how to implement N-Level Approval for Bid, Auction, PO and Contract? Which steps should I follow for        N-Level Approval? Can any one send me sample code and name of BADI where I have to implement the code.
    Abhijeet Panse

    Hi
    Please check for <b>BBP_WFL_APPROV_BADI</b> using SE18 transaction for relevant Code as well and standard SAP documentation.
    Related sample code and other useful pointers ->
    WS14500015 is not working for Multilevel approval
    Re: SRM / Shipping cart
    Re: N Step Approval BADI - BBP_WFL_APPROV_BADI
    Re: N-step BADI workflow
    http://help.sap.com/saphelp_srm50/helpdata/en/8b/4fa9585db211d2b404006094b92d37/content.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/2c/e68d406b305537e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/17/40a86c773d6c41801d78af1a34b90f/frameset.htm
    Multiple Implementation For BBP_WFL_APPROV_BADI
    Re: Help needed on N-Step Approval WFL for SC
    Re: N-Step 14000109 workflow - Unable to identify Approvers
    Do let me know.
    Regards
    - Atul

  • How to implement data level security

    How to implement data level security in BI Publihser?. I am using Obiee enterprise edition and bi publihser. My requirement is to show data based on User- Region relation ship.
    User A - belongs to Eastern Region
    User B - belongs to Southern Region
    so if user A logged in he should see only Eastern Region report. If user B logged in He should see only Southern region. I am using direct sql to my oralce database as data source.
    i appriciate your help

    I am using a common database username and password for jdbc connection. what i am looking is based the BI Publihser login, is there any way?
    say i have userregion table joined with fact. so that i can write a query to get the data
    select c1,c2,c3
    from userregion, fact
    where fact.region=userregion.region
    and userregion.user = BIPUBLIHSERUSER
    but my question is ithere any variable to tell who is logged in BI Publisher? Any server varaibles?
    Other related question is, In every report i want to show User name who is running the report. How can i get this?

  • How to implement row level secuirty at universe level

    Hi All
    How can we implement row level security in universe ?
    John

    HI,
    Can we try this?
    Open designer >>tools>>Manage security>Manage access retrictions
    Click on "new" under available restrictions area .
    Select "rows" tab click add select the table and an appropriate where condition.
    Click ok .
    Add a user\group on which the retriction is to be imposed Click Ok.
    Hope this will help
    Kultar

  • How to implement row level security?

    Hi all,
    There is a database which is for 3 companies to use it and how to use row level security to make sure that they can only manipluate their own data? For example, "employee" table, for each company they just can see their own employees information. How to use dynamic view to do it?
    Many Thanks
    Amy

    Here are two options to achieve what you want.
    A. You can do this by coding, that's if you are ready to. Are you? If yes then try the steps below:
    1. create a security codes table. Say for example
    001 - company a
    002 - company b
    2. create a security table that will list all users and which company they should have access to. You can also implement this by roles.
    3. alter all tables in the application schema to add a security code column. This will be a foreign key reference to table created in 1 above.
    4. update all data in the tables according to which company they belong to.
    5. write a procedure or package that does a validity check whenever a user requests for data. This procedure/package determines which company data the user has access/rights to.
    With this, you should be able to achieve what you want if you do not want to spend on VPD and FGAC. The problem comes where there are users who would have cross access to data from both companies. In this regard, then you have to modify your security table a little bit to handle this.
    B. This option i will admit is not so clean. You can also achieve this by two different views for every table in the application schema. And on each of these views, create a private synonym for every user. For illustration purposes:
    Table name = Employee.
    Create a view employee_a on employee
    create a view employee_b on employee
    Let's say you have users x and y. X has access to employees of company a and y has access to employees of company b. You can now create private synonyms for each of these users as follows:
    create synonym employee on employee_a in x schema.
    create synonym employee on employee_b on y schema.
    This i have not tried but believe should work.
    Hope one of these options serve your purpose.

  • How to implement row level security using external tables

    Hi All Gurus/ Masters,
    I want to implement row level security using external tables, as I'm not sure how to implement that. and I'm aware of using it by RPD level authentication.
    I can use a filter condition in my user level so that he can access his data only.
    But when i have 4 tables in external tables
    users
    groups
    usergroups
    webgrups
    Then in which table I need to give the filter conditions..
    Pl let me know this ...

    You pull the Group into a repository variable using a session variable init block, then reference that variable in the data filters either in the LTS directly or in the security management as Filters. You reference it with the syntax VALUEOF("NQ_SESSION.Variable Name")
    Hope this helps

  • How to implement Dimension Level Security on Tabular?

    Not possible on SQL Server 2014 SSAS Tabular? How to work around?
    Kenny_I

    Hi Kenny_l,
    According to your description, you want to implement dimension security in SSAS 2014 tabular. Right?
    In Analysis Services Tabular mode, dimension level security (based on role permission) is not supported. This security can only used in Multi-dimension mode. In tabular mode, we can only use row-level security based on role permission.
    Please refer to links below:
    Implement Dynamic Security by Using Row Filters
    Reference:
    Comparing Tabular and Multidimensional Solutions (SSAS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou
    TechNet Community Support

  • How to implement column header sort

    Hi all,
    Does anyone know how to configure Oracle 9i AS Portal Release 2 column header sort.
    In Portal, Oracle has setup the IDE to sort your columns using arrow keys in the
    column headers. I would like to do the same thing without using the Custom Form.
    TIA,
    Daniel N

    I would suggest using the built in Collections framework for sorting.
    have class A implement the Comparable interface then implement the compareTo method as follows:
    public int compareTo(Object o) {
        A a = (A)o;  // <-- may cause ClassCastException if (o instanceof A) != true, but that should not be a problem.
        int value = attr1.compareTo(a.attr1);
        if (value != 0) return value;
        value = attr2.compareTo(a.attr2);
        if (value != 0) return value;
        value = a.attr3.compareTo(attr3);  //Notice I switched a.attr3 and attr3 for desc
        return value;
    }That should do it for you.
    Now put everything into an instance of java.util.List and pass that to java.util.Collections.sort(java.util.List);
    If you didn't create class A, and therefore can't add a method to it, then implement a Comparator. The idea is the same, just look at the java.util.Comparator API and use java.util.Collection.sort(java.util.List, java.util.Comparator) method to sort;

  • How to implement row-level security in Discoverer?

    Dear all,
    I have a scenario that I have 2 folders containing sales and inventory data stored by product lines.
    The 2 folders are constructed by 2 SQL statements.
    There exists a set of tables controlling which product line's sales and inventory data a person can read.
    A function is written previously that returns the WHERE clause based on user_id, employee_id and the other parameter.
    So, can you suggest how to integrate the 2 components in Discoverer?
    thanks
    George
    My blog: http://hktour.blogspot.com

    hi Rod,
    Thanks for your suggestions.
    I took your 1st option, ie.
    "You can use VPD at the database level to secure the tables."
    I have a view BUDGET_V with the following columns:
    PERIOD_YEAR
    PERIOD_MONTH
    PRODUCT_LINE
    BUDGET_AMOUNT
    Every salesman can only read the budget amount of certain product lines.
    I built the security function which will be binded to the view BUDGET_V (see below)
    FUNCTION security_policy_function( p_schema in varchar2, p_object in varchar2)
    return varchar2
    as
    begin
    if (user = p_schema) then
    return '';
    else
    return viewProductLine(FND_GLOBAL.USER_ID, FND_GLOBAL.EMPLOYEE_ID, 'BUDGET_V.PRODUCT_LINE');
    end if;
    end;
    The security function actually calls my own security function viewProductLine(FND_GLOBAL.USER_ID, FND_GLOBAL.EMPLOYEE_ID, 'BUDGET_V.PRODUCT_LINE') which take the user id and employee id of the apps user and returns the predicate.
    Then, I bind the security function security_policy_function() to the view BUDGET_V with
    begin
    dbms_rls.add_policy
    object_schema => 'APPS',
    object_name => 'BUDGET_V',
    policy_name => 'MY_POLICY',
    function_schema => 'APPS',
    policy_function => 'security_policy_function',
    statement_types => 'select',
    update_check => FALSE,
    enable => TRUE
    end;
    The problem now is that if I query the view in Discoverer as a Apps user (say "A"), it returns all the records in the view without any filtering (user "A" is supposed be able to read certain product lines).
    I try to verify whether the security function work or not. So, I hardcoded FND_GLOBAL.USER_ID and FND_GLOBAL.EMPLOYEE_ID as 1234 and 6789 which are the user_id and employee_id of user "A". (see below)
    FUNCTION security_policy_function( p_schema in varchar2, p_object in varchar2)
    return varchar2
    as
    begin
    if (user = p_schema) then
    return '';
    else
    return viewProductLine(1234, 6789, 'BUDGET_V.PRODUCT_LINE');
    end if;
    end;
    This time, Discoverer returns only the records with product lines visible to user "A".
    So, I guess there is problem in the function call in viewProductLine(FND_GLOBAL.USER_ID, FND_GLOBAL.EMPLOYEE_ID, 'BUDGET_V.PRODUCT_LINE');
    Can you give me some light on this issue?
    thanks
    George (HK)
    My blog at http://hktour.blogspot.com

  • How to implement Aggreagtion level

    Hi Every One,
    I created Aggregation level and based on that created Planning Function..
    When using the t-code ' RSPLAN ' to create planning sequence , there in the edit sequence screen Filters are not populating for particular Planning function.
    Can anyone suggest the solution for how to populate the filter values in the above mentioned area.
    Regards,
    Sreeni

    Hi Sreeni,
    Could you please be more specific about "Filters are not populating"? What exactly is the error you hit?
    Basically you need to create filter for a aggregation level in RSPLAN -> click button 'filters'
    And for planning topic, could you please discuss it in forum: http://scn.sap.com/community/data-warehousing/business-planning/content
    experts for planning are there.
    Best regards,
    Giselle

  • How to implement method level authorisation in JSF

    Hi all,
    I am new to JSF 2. I have been able to implement authorization on my web pages, but I also want to implement it at the bean level. Does JSF 2 provide an in-built functionality to implement role-based authorization on bean methods? Or, I need to use some security frameworks (i.e. ACEGI)?
    Thanks in advance,
    Neeraj

    I am curious: can you explain WHY you want method level security? It seems woefully overkill and paranoid to me - server level security should be enough to keep out rogue code.
    Anyway for that level of security, the security measures built into the JVM should be used.
    [Java Security documentation|http://java.sun.com/javase/technologies/security/]
    You can also look into a security API like Spring security - be warned though, it has a steep learning curve.

  • How do I structure Information in three Levels in MDM 7.1?

    Hi,
    I am creating a Service Catalogue for a customer. They require three levels in the catalogue: "Packed Services" that are built up by several "Services", that can have several "Supporting Services".
    I am thinking  of using two main tables, and tuples to create BOS for Packed Service and Service. But how should I take care of the lowest level? They wish to be able to order Supporting Services separatly, so I dont think i can put it in a Qualified field in the Service Main Table.
    How about Relationships? Are they on the way out?
    Any suggestions? Is there other ways to structure data in MDM 7.1?
    Kind Regards,
    Thomas

    In the paragraph tab. You may have to open it the first time from the Window menu.
    Chris
    Adobe Enterprise Developer Support

  • How to Implement Sort, Filter funtinality in Normal web dynpro ABAP Table

    Hello,
    How to Implement Sort, Filter funtinality in Normal web dynpro ABAP Table ?
    Thanks

    hi,
    Check out this link for sorting in Table.
    Sorting option in WebDynPro ABAP UI Table
    steps to follow :
    ->Have the data in internal table (itab).
    ->Now use sort command for the particular column which ever you want to sort.
      e.g sort itab descending by <Column>.
    ->Now you can bind the internal table with the Context Node which is binded to Table.
    I hope it helps.
    Thanx.

  • How to implement sorting on a group of records by clicking on the header?

    I am using Oracle Forms 6i. Now I have a table of records having a column header in a custom form. Now I want to sort that column data by clicking on the column header (showing an arrow mark of asc/desc while I press the button). How to implement this? A sample code will be very helpful.

    Hi
    We can't set value to system forms dbdatasource , only getvalue is allowed .
    For i = 1 To oMatrix.RowCount
           oEditText = matrix.GetCellSpecific("column name", i)
           oEditText .String="15"
    Next
    Regards
    Arun

Maybe you are looking for