Find the 20 max values

Say i have an array of 40 doubles. How can i find the 20 maximum values from my array?

Do you know how to sort?
Can you use the Java APIs?ha ha..
yeah.. sort the array and pick the 20.
Or if you write something like a bubble sort, let the outer loop executing half times as the usual..

Similar Messages

  • How to find the second max value

    i have a table named customer, which have a column named salary ,how can i find the customer number which have the second largest salary.

    this example might be of help.
    SQL> select empno, ename, sal, job,
      2         rank() over (partition by job order by sal desc) rank
      3    from emp;
         EMPNO ENAME             SAL JOB             RANK
          7902 FORD             3000 ANALYST            1
          7788 SCOTT            3000 ANALYST            1
          7934 MILLER           1300 CLERK              1
          7876 ADAMS            1100 CLERK              2
          7900 JAMES             950 CLERK              3
          7369 SMITH             800 CLERK              4
          7566 JONES            2975 MANAGER            1
          7698 BLAKE            2850 MANAGER            2
          7782 CLARK            2450 MANAGER            3
          7839 KING             5000 PRESIDENT          1
          7499 ALLEN            1600 SALESMAN           1
         EMPNO ENAME             SAL JOB             RANK
          7844 TURNER           1500 SALESMAN           2
          7521 WARD             1250 SALESMAN           3
          7654 MARTIN           1250 SALESMAN           3
    14 rows selected.
    SQL> select e.empno, e.ename, e.sal, e.job
      2    from (select empno, ename, sal, job,
      3                 rank() over (partition by job order by sal desc) rank
      4            from emp) e
      5   where e.rank = 2;
         EMPNO ENAME             SAL JOB
          7876 ADAMS            1100 CLERK
          7698 BLAKE            2850 MANAGER
          7844 TURNER           1500 SALESMAN

  • Find the abs(max/min) value error.

    Hi,  SAP experts
    Now I want to find the Abs(max) and Abs(min), (you know, for the displacement, if we want to find the max and min, we have to consider it both "+" and "-"), I use the code:
    local numbervar i;
    local currencyVar min;
    local currencyVar max;
    For i := 1 to GetNumRows-1 do
        If i = 1 then
            min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
            max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
        else
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) <= Abs(min) then
                min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) >=  Abs(max) then
                max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
    if CurrentFieldValue In [max, min] then
        crBold
    else
        crRegular
    But it seems not correct, why?

    Hi Hu,
    See if this works:
    local numbervar i;
    local currencyVar min;
    local currencyVar max;
    For i := 1 to GetNumRows-1 do
        If i = 1 then
            min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
            max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
        else
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) <= Abs(min) then
                min := Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex));
            If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) >=  Abs(max) then
                max := Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex));
    if Abs(CurrentFieldValue) In [max, min] then
        crBold
    else
        crRegular
    -Abhilash

  • Limits for pricing in the VK11 - Max Value

    Hi,
    I am working on ECC 6.0.
    I have been trying to use the Max number of orders and Max cond value for a Z condition type . The Max number of orders seems to be working, if I set to 2 the 3rd order does not have the condition type at all.But when I set the max condition value
    it is not working even after reaching the max condition value. If anyone has faced such an issue before kindly help.
    I had set the limits for pricing in the VK11 - Max Value condition,But of no use.
    My calculation type is percentage and the scale base is value in the condition type.
    Regards
    Manoj

    Hi Manoj,
    If u r maintaing Max condition value
    For exp: Material Price A= $100
    max condition value is = $10000
    when u creating 1st order with this material for 50 qty = $5000 is completed
    for 2nd order if u r taking 100 also system will put the net value is $5000 only it will not consider remaining 50..
    if u r placing 3rd order with any qty then net value will come zero..
    that effect u can find from this..
    if i am wrong plz corect mee..
    Regards
    Durga Prasad

  • How would I find the most common value every nth row in a column

    SCENARIO 1
    I have a column with a series of numbers in c1:c1000 as follows:
    2
    2
    3
    1
    1
    4
    2
    3
    1
    2...
    and I would like to find the most common value for every nth (in this case, second) row.
    SCENARIO 2
    Originally, I created a separate column in J and used this to find a value of 0 or 1 via a filter to label the rows odd or even. I was then going to create two separate columns, one for even rows of data and another for odd rows of data to separate them and perform functions on each column. But I do not know how to copy just the filtered data to one of the new columns to apply the MODE function (or any other for that matter).
    Perhaps my question should be: after applying a filter, how do i copy just the visible filtered data of every nth row to a new column in my spreadsheet while retaining the original column with all rows of data? 
    BACK TO SCENARIO 1
    If I do not need to go through this effort, I would just apply the MODE function (or AVERAGE or SUM) to every nth row in the original data column.

    Since Index and Offset were already taken, I used INDIRECT(ADDRESS()) in my example.
    Here's how I approached it:
    Expressions are as follows...
    Data Subset, Column A, Row 2: =IF(StartingRow :: A, 1, NSelector :: $A)
    Subsequent rows in Column A: =IF(ROW()<COUNT(Input :: $B)/NSelector :: A:$A+2, A2+NSelector :: $A, "")
    Data Subset, Column B, Rows 3
    throuth the last: =IFERROR(INDIRECT(ADDRESS(A+1, 2, ,,"Input")), "")
    Stats, Column A, Row 2: =IFERROR(MODE(Data Subset :: B), "No Mode")
    Stats, Column B, Row 2: =COUNTIF(Data Subset :: B, A)
    Lots of ways to skin this cat.
    Jerry

  • Finding the most common value in an array of enums

    Hello,
    I'm looking for an elegant way of finding the most common value in an array of enums
    My enum being:
    0 - Close
    1 - Open
    2 - Undefined
    For instance, if my array contains:
    Close, Close, Open, Close, Close, Open.
    The most common value would be "Close"
    I have created a very customized VI that allows me to obtain the desired result, but I'm really not proud of doing it this way, simply because I would have to modify it if I were to add a new value to my enum...
    If someone can share some ideas to enlighten me, I would REALLY appreciate it.
    Thanks in advance!
    Jorge
    Solved!
    Go to Solution.

    Here is the variant using the search method. This method will run N-1 times where N is the number of ENUM elements. Yes, it is a bit more complex than the brute force method but it would execute fairly quickly. The sort would probably be the time consuming task.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    ENUM Counter.vi ‏14 KB
    Enum.ctl ‏4 KB

  • [svn:fx-trunk] 12552: DataGroup now tracks the indices of the active virtual item renderers with a list , rather than the min/max values.

    Revision: 12552
    Revision: 12552
    Author:   [email protected]
    Date:     2009-12-04 13:45:12 -0800 (Fri, 04 Dec 2009)
    Log Message:
    DataGroup now tracks the indices of the active virtual item renderers with a list, rather than the min/max values. 
    DataGroup/addItemRendererToDisplayList() now respects the overlay.
    QE notes:
    Doc notes:
    Bugs: sdk-24052
    Reviewer:
    Tests run: DataGroup, List
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/sdk-24052
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DataGroup.as

    Hello Martin:
    Thanks for your input.  However I am not certain we have resolved this issue adequately, or understand the principles governing the css as regards this spry menu framework 2.0 (1.0).
    For example, the menu only works in IE 6.0 if the css remains in the head.  I agree with your original post that it shouldn't make any difference whether the css is posted in the head or in a separate style sheet (so long as specificity issues are addressed).  Both should work -- and yet it doesn't.
    If the CSS is placed in the separate style sheet governing the total site, it doesn't work for 6.0.  If placed at the top of the style sheet, conflicts of specificity prevent the menu from rendering properly in any of the browsers causing the rules for general links to govern the menu.   This has been verified using a cross browser testing.  If the styles are placed at the bottom of the style sheet to help them take precedence, they work in all the browsers except for IE 6.
    The website I am building needs to support IE 6 for a variety of reasons, and because it is catering to the non-profit community and to low income persons, I am mindful of even small differences in page weight.
    So for me, at least, the issue remains baffling.
    I appreciate your input, but also would appreciate the input from others, and especially Adobe Community Professionals and employees.  The spry framework in this regard is not well documented.  I am not certain if this is exclusively a CSS problem, if it might also be complicated by the architecture of the spry framework, or if indeed other variables are at play.
    I would be my hope that in resolving the problem, other users of the this particular spry framework might also benefit.
    Thanks,
    Steve.

  • How can I select an area of a picture (larger than one pixel) and find the average RGB values of all the pixels contained inside the area?

    I'm analysing the differences between several different images and I would like to select a large area of each (such as with lasso tool) and find the average RGB value of all of the pixels within the selection area made/

    With the selection you could do a copy paste and use the histogram of the new layer set the histogram source to selected layer.  The eye dropper sample size may also to get the average  of a square area around a point.

  • How to find the last string value in dynamic object?

    Hi All,
    I am trying to find the last string value in dyanamic objects,Any one have solution for this.
    Ex:
    my data :12347-ebjdone-525-ecgfjf-25236-defdafgdeg
    And i want to show the output is :defdafgdeg
    Any ideas:
    Thanks
    Srini

    For oracle try using oracle function.
    e.g.
    SELECT  reverse(substr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),1,instr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),'-','1'))) from dual
    Object definition might look like:
    reverse(substr(reverse({ObjectName}),1,instr(reverse({ObjectsName}),'-','1')))
    Regards,
    Kuldeep
    Edited by: Kuldeep Chitrakar on Feb 12, 2010 8:12 AM

  • Warning: Could not find the customization level value for document

    Hi All,
    I am trying to upload the translation for one of the page at responsibility level.
    I am getting following warning when running the below command.
    java oracle.jrad.tools.trans.imp.XLIFFImporter $APPL_TOP/xmci/12.0.0/fr-CA/Translated/ARIACCTDETAILSPAGE.xlf -username apps -password apps -dbconnection "$AD_APPS_JDBC_URL"
    Warning: Could not find the customization level value for document "/oracle/apps/ar/irec/accountDetails/webui/customizations/responsibility/51688/ARIACCTDETAILSPAGE".
    The same is working fine if the translation is for some attribute at site or function level.
    Did anyone faced this kind of issue.
    Thanks,
    Anoop

    Anoop,
    I am sure you would have verified the responsibility id in the target instance is 51688(may be source instance your resp id is 51688 and in target it is different).
    Have a look at this below notes, it might help.
    1077267.1 - Unable To Move Resp Level OA Personalization From 1 Env To Another
    848851.1 - Attempting To Upload XML File Generates Error: Could not find the customization level value for document
    Thanks.
    With Regards,
    Kali.
    OSSI.

  • Find Index for max value of array

    I can use arrayMax to get the max value for a small array, but I need to get which index the max value is located. That will determine which page the user goes to next. Here is my code:
    array:
    <cfset arrAverages[1]="#qryFairness.fairness#"/>
    <cfset arrAverages[2]="#qryHonesty.honesty#"/>
    <cfset arrAverages[3]="#qryCompassion.compassion#"/>
    <cfset arrAverages[4]="#qrySelfControl.SelfControl#"/>
    <cfset arrAverages[5]="#qryMoralConcern.MoralConcern#"/>
    These values are gathered from querying values stored in a table.
    I can get the max value in the array easily by:
    <cfdump var="#arrayMax(arrAverages)#">
    What I can't figure out is how to get the row in this array where that max value is located. It seems like it would be so simple, but nothing I have tried has worked.
    Thanks,
    Richard

    rking1966 wrote:
    I can use arrayMax to get the max value for a small array, but I need to get which index the max value is located. That will determine which page the user goes to next. Here is my code:
    array:
    <cfset arrAverages[1]="#qryFairness.fairness#"/>
    <cfset arrAverages[2]="#qryHonesty.honesty#"/>
    <cfset arrAverages[3]="#qryCompassion.compassion#"/>
    <cfset arrAverages[4]="#qrySelfControl.SelfControl#"/>
    <cfset arrAverages[5]="#qryMoralConcern.MoralConcern#"/>
    These values are gathered from querying values stored in a table.
    I can get the max value in the array easily by:
    <cfdump var="#arrayMax(arrAverages)#">
    What I can't figure out is how to get the row in this array where that max value is located. It seems like it would be so simple, but nothing I have tried has worked.
    You can find it in one line of code! Here is an example:
    <cfset testArr[1]=-183>
    <cfset testArr[2]=79>
    <cfset testArr[3]=6>
    Max.:  <cfoutput>#arraymax(testArr)#</cfoutput><br>
    Index of max.: <cfoutput>#arrayfindNocase(testArr, arraymax(testArr))#</cfoutput>

  • How to find the user entered value is Integer or not?

    hi,
    i want to find, whether the user entered value is Integer or not. If it is Integer, i wanna continue the program. otherwise send an error message. i tried to find for function in API. But i couldn't. can somebody help me with sample code. very urgent.

    Do a Integer.parseInt(<string value>) in a try catch block If a NumberFormatException is thrown, the entered number is not an integer.

  • How to find the most matched values in the set of map?

    Hi friends!
    I have two vectors
    vector<int> V1; vector<int> V2;
    and a map<int, set<int>> M1;
    I want to select common values from both V1 and V2 and check those values with the set in the map M1.
    For example:
    V1 contains;
    2  4  6  8  9
    V2 contains;
    4  5  6  9  10 
    M1 contains;
    1=>1  2  5  9
    2=>4
    3=>5   10
    4=>2  4  8
    5=>4   9
    6=>4   6
    7=>9  12
    When we select the common values of V1 and V2 it is 4, 6, 9.
    And we search for all 4, 6, 9 from the values of M1 which give more appropriate.
    But, no all values in the set of map.
    Then, we delete any value from 4, 6, 9, then remaining values would match any values from the map.
    From the example, if we delete 6, then remaining 4, 9 will match with 5=>4  9, or if we delete 9, then 6=>4   6. Any one of the keys can be selected.
    I know how to select the common values from V1 and V2, but I do not know how to match with the values and select the appropriate key from M1.
    Could anyone help me to solve this?

    This is not the question you asked, except perhaps in the subject. The subject is not the right place to put key features of the question. It is also important to use the body to ask just the question you want
    answered. For example your real question has nothing to do with V1 and V2, just the common vector V (e.g. 4 6 9).
    One way to solve your problem would be to create a new map
    map<int, set<int>> M2;
    with the same keys as M1. Each set of M2 should contain the elements of V that are
    not in the corresponding set of M1.
    Then pick the key of M2 that has the smallest set. If that set is empty, then the whole of V can be used. Otherwise the smallest set tells which elements of V have to be removed, and which is the desired key of M1.
    In your example, key 5 of M2 will contain just 6, so you should remove 6 from V and select key 5.
    Yes fine. I tried the following code and it creates the map M2 (NewMyMap in my code). But how to find the smallest set starting from size 1?
    #include <vector>
    #include <algorithm>
    #include <iostream>
    #include <map>
    #include <set>
    using namespace std;
    typedef vector<int> IntVec;
    typedef set<int> IntSet;
    typedef map<int, IntSet> SetMap;
    bool IsValueNotInSet(int value, IntSet& S);
    SetMap CreatNewSetMap();
    IntVec IVec; //This vector is for selecting certain keys from mySet map.
    IntVec myVec;
    SetMap mySet;
    SetMap NewMyMap;
    int main()
    IVec.push_back(3); IVec.push_back(4); IVec.push_back(5); IVec.push_back(6);
    myVec.push_back(4); myVec.push_back(6); myVec.push_back(9);
    IntSet tempS;
    tempS.insert(1); tempS.insert(2); tempS.insert(5); tempS.insert(9);
    mySet.insert(make_pair(1,tempS));
    tempS.clear();
    tempS.insert(4);
    mySet.insert(make_pair(2,tempS));
    tempS.clear();
    tempS.insert(5); tempS.insert(10);
    mySet.insert(make_pair(3,tempS));
    tempS.clear();
    tempS.insert(2); tempS.insert(4); tempS.insert(8);
    mySet.insert(make_pair(4,tempS));
    tempS.clear();
    tempS.insert(4); tempS.insert(9);
    mySet.insert(make_pair(5,tempS));
    tempS.clear();
    tempS.insert(4); tempS.insert(6);
    mySet.insert(make_pair(6,tempS));
    tempS.clear();
    tempS.insert(9); tempS.insert(12);
    mySet.insert(make_pair(7,tempS));
    cout<<"MYVEC\n";
    cout<<"-------------\n";
    for(IntVec::iterator itv = myVec.begin(); itv != myVec.end(); ++itv)
    cout<<(*itv)<<" ";
    cout<<"\n\n";
    cout<<"\nMYSET\n";
    cout<<"-------------";
    for(map<int,set<int>>::iterator its = mySet.begin(); its != mySet.end(); ++its)
    cout << endl << its->first <<" =>";
    for(IntSet::iterator sit=its->second.begin();sit!=its->second.end();++sit)
    cout<<" "<<(*sit);
    cout<<"\n\n";
    NewMyMap= CreatNewSetMap();
    cout<<"\nNEWMYSET\n";
    cout<<"-------------";
    for(map<int,set<int>>::iterator its1 = NewMyMap.begin(); its1 != NewMyMap.end(); ++its1)
    cout << endl << its1->first <<" =>";
    for(IntSet::iterator sit=its1->second.begin();sit!=its1->second.end();++sit)
    cout<<" "<<(*sit);
    cout<<"\n\n";
    return 0;
    bool IsValueNotInSet(int value, IntSet& S)
    IntSet::iterator it=find (S.begin(), S.end(), value);
    if (it!=S.end())
    return false;
    return true;
    SetMap CreatNewSetMap()
    IntSet TSet;
    for(IntVec::iterator it = IVec.begin(); it != IVec.end(); ++it)
    SetMap::iterator its = mySet.find(*it);
    if (its != mySet.end())
    TSet.clear();
    int key = its->first;
    IntSet& itset = its->second;
    for(IntVec::iterator itv = myVec.begin(); itv != myVec.end(); ++itv)
    if(IsValueNotInSet((*itv), itset))
    TSet.insert(*itv);
    NewMyMap.insert(make_pair(key,TSet));
    return NewMyMap;

  • Unable to find the column pay value and monthly salary in element entries

    hi,
    iam unable to find the payvalue and monthly salary in element entries form.
    people enter and maintain> assignment > entries >entry values..
    please tell me the table and column where the payvalue and monthlly salary is going to get populate.
    Thanks,
    vijetha.c

    It seems that you're using an application to connect to an Oracle database. It's general Oracle Database Forum, so you should put your question under correct topic
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to Finding the Last Row Value in Datagrid?

    Hi Everyone,
    Thanks in Advance.
    I need your help, to find the last row data in Datagrid.
    Actually i am using Datagrid to display my Data in flex. In my data i stored the gender value of employees. So if the last row in my datagrid is "female" i need to be highlight that particular row. So please help me to solve this issue.
    Thanks,
    Charles. J

    datagrid.selectedIndex = datagrid.dataprovider.length;
    ^ something like this will select the last row in the datagrid.
    if you need to check it's value, you might need to cast an object here, based on the index value, and check it's gender value.
    datagrid.selectedIndex = datagrid.dataprovider.length;
    if (datagrid.selectedItem["gender"] == "female") {
    //handle here

Maybe you are looking for