Descending order for arrays by name

Hi, thank you to all the people who previously helped me before....
Is there a way to sort an array in decending order by name?
I was trying to figure out what to do but this is what i have so far
double [] Salary = new double [10];
String [] Names = new String [10];
int i, j;
for ( i = 0; i < 10; i++)
System.out.print(" Name is: " + Names);
Names[i] = ReadInput.StringRead(); //asks user for Salry
System.out.println(" Salary is: " + Salary[i] );
Salary[i] = ReadInput.readDouble(); //asks user for Names
for (j=0; j < 10; j++)
System.out.println(Names[j] + ": " + Salary[j]);

Smckee6452, thank you for helping me.....
i think i am getting close, but the sorting part (descending by names)part of the code is not working too well
did i miss something??
public class Compare {
public Compare() {
double [] Salary = new double [10];
String [] Names = new String [10];
String nameTemp = new String();
double salaryTemp = 0.0;
for (int i = 0; i < 10; i++)
System.out.print(" Name is: " + Names);
Names[i] = ReadInput.StringRead(); //asks user for Salry
System.out.println(" Salary is: " + Salary[i] );
Salary[i] = ReadInput.readDouble(); //asks user for Names
// for (int j=0; j < 10; j++)
// System.out.println(Names[j] + ": " + Salary[j]);
for (int i = 0; i < 9; i++)
for ( int j = 1; j < 10; j++)
{    //do compare and swapping in here
nameTemp = Names[i];
Names[i] = Names[j];
Names[j] = nameTemp;
salaryTemp = Salary[i];
Salary[i] = Salary[j];
Salary[j] = salaryTemp;
System.out.print(nameTemp);
System.out.println(salaryTemp);

Similar Messages

  • TS2512 i m trying to convert dpx files to mov in colour 1.5.3 but in file browser files are not seen in proper order for ex files names are 12345 it is coming as 23145 bcoz of which in output also its coming in wrong order

    i m trying to convert dpx files to mov in colour 1.5.3 but in file browser files are not seen in proper order for ex files names are 12345 it is coming as 23145 bcoz of which in output also its coming in wrong order

    1) What you downloaded should be a packed file (zip, tar.gz, etc) that needs to be unpacked into the directory of your choice.
    2) & 3) are answered by Ant's installation documentation (the page you're quoting from):
    http://ant.apache.org/manual/index.html

  • Displaying Array Position not working in case of descending Order?

    Hi,
    I need to display the array position of the sorted array in Descending order. Here is my code.
         int[] in = {5,3,2,7};
              int[] newArr = new int[in.length];
              int[] na = new int[in.length];
              //copying into a new array
              for(int i=0;i<in.length;i++){               
                   newArr[i] = in;     
              // code for descending order
              for(int j=0;j<in.length;j++){
              Arrays.sort(in);
              na[j] = in[in.length-(1+j)];
              }the sorted array will be will be {7,5,3,2} now according to this i need to display the array position of the sorted array which should be {3,0,1,2} i tried to compare newArr[i] with na[j] but am not gettin the result that i should be getting the same comparison is working in case of Ascending Order but not descending. Any suggestions or help will be appreciated.
    Thanks and regards.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hi,
    what you are doing is correct only, do not put sort method inside the for loop
    and postion is correct also
    int[] in = {5,3,2,7};
            int[] newArr = new int[in.length];
            int[] na = new int[in.length];
            //copying into a new array
            for(int i=0;i<in.length;i++){
                newArr[i] = in;
    Arrays.sort(in);
    // code for descending order
    for(int j=0;j<in.length;j++){
    na[j] = in[(in.length-1)-j];
    System.out.println("Val --> "+na[j]);
    System.out.println("Position --> "+j);

  • Can you sort a multi value field in descending order on a BC?

    Hi
    We have a date field which is a multivalue field on our Enrolment BC. The field comes from our Attendance BC. The Enrolment BC has a one to many relationship with an Attendance BC.
    We would like to sort this date in descending order for use on the Enrolment BC. We tried this on the link using the associated list sort spec. However this did not work.
    The only way we could get the multi value field to sort by descending order on the Enrolment BC was to add a sort spec on the Attendance BC. That is Date (DESC).
    Is there any other to do this using configuration? We don't want to add a sort spec on the Attendance BC to do this. At the moment it looks we will need to use script on the Enrolment BC.
    Thanks for you help,
    Tim

    That is a good suggestion. It looks like we already have a couple of cloned "Attendance" BC's used by workflow / interfaces so maybe I can use one of these. Thanks!

  • Sorting a two dimensional array in descending order..

    Guy's I'm a beginning Java programmer. I've been struggling with finding documentation on sorting a two dimensional primitive array in descending order.. The following is my code which goes works, in ascending order. How do I modify it to make the list write out in descending order?
    class EmployeeTable
         public static void main(String[] args)
         int[][] hours = {
              {2, 4, 3, 4, 5, 8, 8},
              {7, 3, 4, 3, 3, 4, 4},
              {3, 3, 4, 3, 3, 2, 2},
              {9, 3, 4, 7, 3, 4, 1},
              {3, 5, 4, 3, 6, 3, 8},
              {3, 4, 4, 6, 3, 4, 4},
              {3, 7, 4, 8, 3, 8, 4},
              {6, 3, 5, 9, 2, 7, 9}};
         int [] total = new int [hours.length];
         for (int i = 0; i < hours.length ; i++){
              for (int j = 0; j < hours.length ; j++){
                   total[i] += hours[i][j];
         int[] index = new int[hours.length];
         sortIndex(total, index);
    for (int i = 0; i < hours.length; i++)
    System.out.println("Employee " + index[i] + " hours are: " +
    total[i]);
    static void sortIndex(int[] list, int[] indexList) {
    int currentMax;
    int currentMaxIndex;
    for (int i = 0; i < indexList.length; i++)
    indexList[i] = i;
    for (int i = list.length - 1; i >= 1; i--) {
    currentMax = list[i];
    currentMaxIndex = i;
    for (int j = i - 1; j >= 0; j--) {
    if (currentMax < list[j]) {
    currentMax = list[j];
    currentMaxIndex = j;
    // How do I make it go in descending order????
    if (currentMaxIndex != i) {
    list[currentMaxIndex] = list[i];
    list[i] = currentMax;
    int temp = indexList[i];
    indexList[i] = indexList[currentMaxIndex];
    indexList[currentMaxIndex] = temp;

    Bodie21 wrote:
    nclow all you wrote was
    "This looks to me like a homework assignment that you're asking us to solve for you. Your description of what it does isn't even correct. It doesn't sort a 2d array.
    You would probably elicit better help if you could demonstrate that you've done some work and have something specific that you don't understand."
    To me that sounds completely sarcastic. You didn't mention anything constructive besides that.. Hence I called you a male phalic organ, not a rear exit...Bodie21, OK, now you've got 90% of us who regularly contribute to this forum thinking your the pr&#105;ck. Is that what you wanted to do? If so, mission accomplished. Many will be looking for your name next time you ask for help. Rude enough for you?

  • How to show employee names in descending order but 3rd row is fixed and always top on the table ?

    how to show employee names in descending order but 3rd row is fixed and always top on the table ?
    for example employee names is A,B,C, D, E
    and output is     C,E,D,B,A

    Since you are posting in the design forum, the short answer is - you don't.  Rows in a table have no inherent order that you can rely on and the "position" of rows is a visual characteristic that should be implemented by the application that displays
    this information or by the query that is used to generate the resultset.  
    So the next question is how one accomplishes this particular order within a select statement.  That is a tsql question which, for future reference, is best posted to the tsql forum.  In addition, many of the questions or issues that you will face
    have been discussed in the forums - often many, many times.  The first thing you should do when faced with an issue is to simply search the forums and leverage the the knowledge that has already been discussed.  In doing so you are quite likely to
    see suggestions or related issues that you should consider in your search for a solution.  
    Now, to answer the question - you need to formulate a order by clause that forces the rows to be sorted in the manner you desire.  Effectively you have 2 levels of sorting.  The first level divides your rows into 2 groups.  Group 1 consists
    of rows where name = E and Group 2 is everything else.  Following that you then need to sort the rows in each group by name in descending order.  Something like:  
    order by case name when E then 1 else 2 end, name desc

  • I ordered Illustrator for another user.  I received an invitation that was accepted, logged in and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person?

    I ordered Illustrator via creative cloud for another user.  I received an invitation that was accepted  and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person? 

    Cloud as a Gift https://forums.adobe.com/thread/1665610

  • Purchase Order for one Vendor & one ship name.

    How to display all Purchase orders for one vendor and one ship name.
    Its urgent...
    Regards
    Irfan

    What is one ship name? is it Delivery Address..
    Then try ME2N....
    You can choose different fields like Vendor etc...
    in the Dynamic selections....
    Thx
    Raju

  • Using JavaScript need to Sort subsite site collection based on date in descending order

    Hi,
    Below is my code, where i need to sort the " webCollection
    = web.getSubwebsForCurrentUser(null)" web collection based on the web.get_created() in
    descending order. How could i do it any suggestions. Also i need it in JavaScript.
    <script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script>
    <script src="/_layouts/15/SP.js"></script>
    <script type="text/javascript">
    var context = SP.ClientContext.get_current();
    var web = context.get_web();
    ExecuteOrDelayUntilScriptLoaded(getWebProperties, "sp.js");
        function getWebProperties() {
                    webCollection = web.getSubwebsForCurrentUser(null);
            context.load(webCollection)
            //ctx.load(this.web);
            context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
                Function.createDelegate(this, this.onFail));
        function onSuccess(sender, args) {
            //alert('web title:' + this.web.get_title() + '\n ID:' + this.web.get_id()
    + '\n Created Date:' + this.web.get_created());
            alert("Number of sites: " + webCollection.get_count());
                   var webEnumerator = webCollection.getEnumerator();
                    while (webEnumerator.moveNext()){
       var web = webEnumerator.get_current();
      alert("Title="+web.get_title() +"\n"+ "Created="+web.get_created());
        function onFail(sender, args) {
            alert('failed to get list. Error:'+args.get_message());
    //getWebProperties();
    </script>
    Thanks!
    MCTS- Please vote and mark posts as answered where appropriate.

    Hi,
    According to your post, my understanding is that you wanted to sort the subsite based on the date in descending order.
    You can refer to the following code snippets, it sorts the subsites by the date in descending order.
    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    // When the body is loaded, the onload event handler executes each function whose name is contained in this array.
    _spBodyOnLoadFunctionNames.push("callCSOM");
    function callCSOM()
    $("#Button1").click(function()
    ExecuteOrDelayUntilScriptLoaded(RetriveSites, "sp.js");
    var currentcontext = null;
    var currentweb = null;
    function RetriveSites()
    currentcontext = new SP.ClientContext.get_current();
    currentweb = currentcontext.get_web();
    this.subsites = currentweb.get_webs();
    currentcontext.load(this.subsites);
    currentcontext.executeQueryAsync(Function.createDelegate(this, this.ExecuteOnSuccess),
    Function.createDelegate(this, this.ExecuteOnFailure));
    function ExecuteOnSuccess(sender, args)
    var subsites = '';
    var enum1 = this.subsites.getEnumerator();
    var siteCreatedTime = '';
    var array=new Array();
    while (enum1.moveNext())
    var site = enum1.get_current();
    array.push(new Array(site.get_created(),site.get_title()));
    alert(array);
    array=sortMethod(array);
    alert(array);
    function sortMethod(arr) {
    var i, j, stop, len = arr.length;
    for (i=0; i<len; i=i+1)
    for (j=1;j<len - i; j++)
    // change the "<" to ">" would be sort by the Ascending.
    if (new Date(arr[j-1][0]) < new Date(arr[j][0]))
    //swap(j, j+1);
    var temp = arr[j-1];
    arr[j-1] = arr[j];
    arr[j] = temp;
    //alert(new Date(arr[j]));
    return arr;
    function ExecuteOnFailure(sender, args) {
    alert("error");
    </script>
    <input id="Button1" type="button" value="Run Code"/>
    Results:
    Sort before:
    Sort after:
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Jason Guo
    TechNet Community Support

  • How to sort data in descending order when user clicks on the column heading

    Hi
    I have a report called "Top customers", which shows the top customers for a specific product line. It displays the customer name and one column with the total amount spent in the period for each product line. By default, the leftmost product line is sorted in descending order.
    If the user wants to know who are the top customers for another product line, they simply click on the column heading to sort the list by that column.
    The problem is that when you click for the first time on a sortable column heading, Apex sorts it in ascending order; you need to click on the same column heading again to sort in descending order.
    Is it possible to change this behaviour and sort the data in descending order in the first click? So the users don't have to click twice...
    Thanks
    Luis
    PS: Apex 3 running on Oracle 10.2.0

    Luis,
    See: Can I "catch" a click on a sortable column header of a report?
    Take a look at Anton Nielsen's answer with regards to hiding a column and displaying its value instead of the sortable column.
    Asumming the following simple report query:
    select product,sales
    from <table>
    Change that into:
    select product
    ,sales*-1 as reverse_sales -- Select this one as an extra column
    ,sales -- Hide this column
    from <table>
    In your report column attributes (of column reverse_sales), html-expression, type #sales#. It then displays the normal sales. However apex will generate a 'order by 2 asc' for the first time. The '2' will refer to the sales*-1 value: sorting it asc, is the same as sorting sales descending...
    Toon

  • Marker Won't Display When Y Axis in Descending Order

    I'm using an RTF to create charts.  I'm using bi-publisher desktop version 11.1.1 and have Office 10 loaded.
    If I add markerDisplayed="true" to my line chart, the markers display on the line and in the legend.  But, when I add
    <Y1Axis axisMinAutoScaled="false" axisMinValue="1" majorTickStepAutomatic="false" majorTickStep="2" ascending="false" />
    the markers disappear from the lines but stay in the legend.
    For instance, this works (displays markers on lines and legend):
    <Graph markerDisplayed="true" depthAngle="50" depthRadius="8" seriesEffect="SE_AUTO_GRADIENT" graphType="LINE_VERT_ABS"><LegendArea visible="true" /><LocalGridData colCount="{count(xdoxslt:group(.//G_2,  'PERIOD'))}" rowCount="{count(xdoxslt:group(.//G_2,  'BRAND'))}"><RowLabels><xsl:for-each-group select=".//G_2" group-by="BRAND" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><Label><xsl:value-of select="current-group()/BRAND" /></Label></xsl:for-each-group></RowLabels><ColLabels><xsl:for-each-group select=".//G_2" group-by="PERIOD" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><Label><xsl:value-of select="current-group()/PERIOD" /></Label></xsl:for-each-group></ColLabels><DataValues><xsl:for-each-group select="//G_2" group-by="./BRAND" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:variable name="G1" select="current-group()" /><RowData><xsl:for-each-group select="//G_2" group-by="./PERIOD"><Cell><xsl:value-of select="sum($G1[(./PERIOD=current()/PERIOD)]/RANKING[.!=''])" /></Cell></xsl:for-each-group></RowData></xsl:for-each-group></DataValues></LocalGridData></Graph>
    Add the code to sort the Y axis in descending order and start at 1, not o, and the markers disappear from the lines but still show up in the legend:
    <Graph markerDisplayed="true" depthAngle="50" depthRadius="8" seriesEffect="SE_AUTO_GRADIENT" graphType="LINE_VERT_ABS"><LegendArea visible="true" /><Y1Axis axisMinAutoScaled="false" axisMinValue="1" majorTickStepAutomatic="false" majorTickStep="2" ascending="false" /><LocalGridData colCount="{count(xdoxslt:group(.//G_2,  'PERIOD'))}" rowCount="{count(xdoxslt:group(.//G_2,  'BRAND'))}"><RowLabels><xsl:for-each-group select=".//G_2" group-by="BRAND" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><Label><xsl:value-of select="current-group()/BRAND" /></Label></xsl:for-each-group></RowLabels><ColLabels><xsl:for-each-group select=".//G_2" group-by="PERIOD" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><Label><xsl:value-of select="current-group()/PERIOD" /></Label></xsl:for-each-group></ColLabels><DataValues><xsl:for-each-group select="//G_2" group-by="./BRAND" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:variable name="G1" select="current-group()" /><RowData><xsl:for-each-group select="//G_2" group-by="./PERIOD"><Cell><xsl:value-of select="sum($G1[(./PERIOD=current()/PERIOD)]/RANKING[.!=''])" /></Cell></xsl:for-each-group></RowData></xsl:for-each-group></DataValues></LocalGridData></Graph>
    I'm new to bi-pub so please excuse anything that might seem obviously right or wrong to you !
    Krys

    the kext may have gone funky on the Mac. see:
    iPod Updater reports iPod nano or Fifth Generation iPod must be connected using FireWire
    iTunes: No Photos or Videos tab in the iPod preferences pane in Mac OS X
    iPod does not appear in iPod Updater or iTunes in Mac OS X

  • How to Display drop down list in descending order on the web

    Dear BW Guru,
    I am Thambi, Currently I have the user's requirement to display <b>drop down</b> list in descending order on the web.
    1. In my Bw  system <b>0calweek</b> we have 3year's calweeks data (156 - Values), If we list this in <u>Bex Value Help of Info object for Ocalweek</u> Pop up window opens , By clicking  on Info object name we can able to see the values ascending or descending according  our wish.
    2. If we veiw the report in Web, I can able to see only first 25 values in ascending order web.
    3. How to view those valuse in <b>decending order</b> in web.
    Pls help me to solve this problem.
    Thanks in advance.

    Hi John, you should either add the values to your InfoPath dropdown manually or create a new list in SharePoint with the values and make a connection to that list to populate your dropdown.
    cameron rautmann

  • Unexpected value type for Item Tag Name ; expected System.Single, received

    Hi,
    I am using PCo 2.1 with MII 12.1 to extract values from some PI tags. When I run the query, I get this error -
    Unexpected value type for Item <Tag Name>; expected System.Single, received System.String[Value = Scan Off]
    Can somebody explain what I need to do to get the correct result?
    Regards,
    Chanti.

    To make the service return "whatever is passed", you have to take a step back and realize that there is a little understanding of XML Schema required.
    When using a complexType, which is defined as a sequence, then you are implying an ordered sequence of elements. Default value for the 'minOccurs' attribute is 1. It's also important to understand that there is a difference between minOccurs=0 and nillable="true".
    nillable="true" just means that the name element can carry a null value. If you want the name element to be optional, then you must use the minOccurs=0 and keep the maxOccurs to it's default value of 1. Using an array is just a bad work around. This is for deserialization (XML to JAVA).
    The second part of you problem is on the serialization (or JAVA to XML). When you have a JAVA Bean, there is no way to make the difference between a member's value being null or not set, so it's impossible to decide if you need to send back a nul (xsi:nil="true"), an empty element <ns1:name/> or nothing.
    That said, if you do want to go the XML route, you can use the dataBinding="false" flag in the different WSA command. Instead of converting XML into JAVA, you will have SOAPElement parameters, where you can do all you want (see WS user's guide [1] for details - chapter 16). Note that you have to make sure that the WSDL (your contract) reflect what you are doing on the wire (format of your messages), so that you do not geopardize your interoperability with other toolkit.
    Note that this only applies to literal message formats (use attribute in WSDL), which is your case.
    Hope this helps,
    Eric
    [1] http://download-west.oracle.com/otn_hosted_doc/ias/preview/web.1013/b14434.pdf

  • Search PO's in PO Summary form in descending order

    Hi All,
    Normally when we search for Open PO's in PO Summary form, the latest PO will be in bottom of the Lov. Is there a way to see the latest PO on top(i.e, descending order).
    We are on 11.5.10.2.
    Thank you in advance,
    Pramod

    I think by default the latest comes at top but if it is other way around for you, you can do a forms personalization to get it right.
    Trigger Event: WHEN-NEW-FORM-INSTANCE
    Actions:
    Type: Property
    Object Type: Block
    Target Object: HEADERS_FOLDER
    Property Name: ORDER_BY
    Value: ORDER_DATE DESC
    Thanks,
    PS.

  • BAPIs to create sales orders for Returns and Debit Memo Request

    Hi,
    I have to create a sales order for document type Returns as well as a debit memo request.The BAPI 'BAPI_SALESORDER_CREATEFROMDAT2' is giving the following error message for Debit Memo Request document creation as well as for Returns.
    761 Unpermitted combination of business object BUS2032 and sales doc. category L
    I found BAPIs:
    ‘BAPI_CUSTOMERRETURN_CREATE’ for creating sales document of type ZDRE and SD document category ‘H’.
    ‘BAPI_DEBITREQUEST_PROXY_CREATE’ for creating sales document of type ZDDR and SD document category ‘L’.
    please let me know if anybody have used them. If so what values need to be passed to I_UPLOAD_ID,I_DESTIN,I_SFA_REL parameters of BAPI_DEBITREQUEST_PROXY_CREATE. Are there any alternative solutions using the Salesorder bapi.
    I have to create documents based on the flat file data no reference sales document numbers are available.
    Appreciate your help..
    Good Day
    Regards
    Bhargavi

    Look at the code done by me
    Program Name:                                                        *
    SAP Name    : ZAXXXXXX               Version    :                    *
    Programmer  : Chris Dong of ITDC                    *
    Description :                                                        *
    Includes        :                                                    *
    Function Modules: XX_XXXXXX                                          *
    Transactions    :                                                    *
    Programs        :                                                    *
    REPORT  XXXXXXXX LINE-SIZE  80
                     LINE-COUNT 65
                     MESSAGE-ID ZA
                     NO STANDARD PAGE HEADING.
    CLEAR l_order_partners.
    l_order_partners-partn_role = 'AG'.
    l_order_partners-partn_numb = '0001202491'.
    APPEND l_order_partners TO li_order_partners.
    CLEAR l_order_partners.
    l_order_partners-partn_role = 'WE'.
    l_order_partners-partn_numb = '0001202491'.
    APPEND l_order_partners TO li_order_partners.  
    Sales document type
    l_order_header_in-doc_type = 'ZDR'.  
    Sales organization
    l_order_header_in-sales_org = '1000'. 
    Distribution channel
    l_order_header_in-distr_chan = '01'.  
    Division
    l_order_header_in-division = '04'. 
    REF DOCUMENT
    l_order_header_in-REF_DOC = '9100000144'.
    order reason
    l_order_header_in-ord_reason = '925'.
    item number
    l_order_items_in-itm_number = '000001'. 
    material no
    l_order_items_in-material = '000000000007000012'. 
    Qty
    l_order_items_in-target_qty = '0000000000100.000'. 
    APPEND l_order_items_in TO li_order_items_in. 
    *BUS2094 Credit memo request " OSS NOTE 93091
    *BUS2096 Debit memo request " OSS NOTE 93091
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA'
    EXPORTING
    ORDER_HEADER_IN = l_order_header_in
    BUSINESS_OBJECT = 'BUS2096'
    WITHOUT_COMMIT = ' '
    CONVERT_PARVW_AUART = ' '
    IMPORTING
    SALESDOCUMENT = l_vbeln
    RETURN = li_return
    TABLES
    ORDER_ITEMS_IN = li_order_items_in
    ORDER_PARTNERS = li_order_partners
    Message was edited by:
            Chris Dong
    null

Maybe you are looking for