Sorting numbers stored in variables

I'm completely new at java and would like some help with a certain problem.
I have 5 numbers, num1, num2, num3, num4, and num5.
I have them stored in variables as listed. I'd like to know, is there a way to sort them using array.sort or would I have to use another method?

I have 5 numbers, num1, num2, num3, num4, and num5.
I have them stored in variables as listed. Are you saying you have 5 different ints declared like
int num1, num2, etc.or an int[] with length 5?
I'd like
to know, is there a way to sort them using array.sort
or would I have to use another method?If they are stored in an array you can use http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#sort(int[])
to sort them.

Similar Messages

  • Sorting Numbers stored in variables....using if/else

    Hey there, I'm curious, how would you sort 3 integers using only five if's and five elses and no other operators besides a < (less than) operator? Some help would be much appreciated! thanks. ishan

    well with the topic i brought back there, didnt
    really follow the boolean, and i couldnt figure out a
    way to simply use only if's elses' and > rather than
    using boolean, and what not.. like for integer a, b,
    c; would i go into the possible permutations and
    start from there? not sure how to go about it..You will need to put them in an array or List. Then you can quicksort them.
    Hmmm let me think....
    if
      length<2 return
    choose pivot
    if less than pivot
      put in left bucket
    else
      put in right bucket
    recurse left bucket
    recurse right bucket
    returnThat's 2 if's and one else.

  • Sorting numbers stored as text

    Business1 stores ItemCode as an alphanumeric, which makes sense.  But we only ever use numbers, so when I try to sort a report by ItemCode, or select a range by ItemCode I get things like this:
    4100
    41001
    4101
    4102
    42001
    42003
    42004
    4201
    Can I get CR to treat these as numbers, and sort/select them as numbers?

    Hi Stuart,
        try to use any one formula given below , and try to short on this formula field
           1] right("00000000" & ,10)
                               or
           2] toNumber()
    You can suppress this field,so it will not be visible to the user
    Regard's

  • "Numbers stored as text" error in Excel when I schedule a report

    Dear all,
    When I schedule a report, I got a "Numbers stored as text" error in Excel.
    But when I save as xls directly from webI, I have no error in the excel sheet.
    So, is it a bug ? I have the BO XI 4.0 version.
    Or is there a special option to set concerning schedule ?
    Mike.

    Hi,
    First check the object data type in webi. Normally this error will come when  object/variable data type is Text in the report.
    If you are getting this error with object data type number then  add 0 in the object and see.
    Like  =[Object] + 0
    It will force the value to be converted in the number.
    Regards,
    Amit

  • How to get values from a stored package variable of type record ?

    Sir,
    In my JClient form, I need to get values from a database stored package variable of type record. And the values are retained in the JClient form for the whole session. The values are copied only once when the form is started.
    What is the best way to do that ?
    Thanks
    Stephen

    Stephen,
    not sure what your model is, but if it is Business Components, I think I would expose the properties as a client method on the application module. This way all JClient panels and frames will have access to it. You could use a HashMap to store the data in teh app module.
    If JDBC supports the record type, then you should be able to call it via a prepared SQL statement. If not, you may consider writing a PLSQL accessor to your stored procedure that returns something that can be handled.
    Steve Muench provides the following examples on his blog page
    http://otn.oracle.com/products/jdev/tips/muench/stprocnondbblock/PassUserEnteredValuesToStoredProc.zip
    http://otn.oracle.com/products/jdev/tips/muench/multilevelstproc/MultilevelStoredProcExample.zip
    Frank

  • How do I add a list of numbers stored in an array

    How do I add a list of numbers stored in an array? The code I
    have is showing ‘NaN’ when I try to add the second item
    in each element of the array:
    var aItemPrices:Array = new Array(["item1_mc", 10], ["item
    2_mc", 20], ["item 3_mc", 30]);
    var totalPrice:Number;
    for (i=0; i<aItemPrices.length; i++) {
    //the following line traces 'NaN'
    totalPrice += aItemPrices
    [1];
    trace("totalPrice: "+ totalPrice);

    i modified your code in 2 places, check it
    var aItemPrices:Array = new Array(["item1_mc", 10], ["item
    2_mc", 20], ["item 3_mc", 30]);
    var totalPrice:Number=0; //Mani changes
    for (i=0; i<aItemPrices.length; i++) {
    //the following line traces 'NaN'
    totalPrice += aItemPrices
    [1];//Mani changes
    trace("totalPrice: "+ totalPrice);

  • Sorting numbers Zen Mozaic EZ 100

    !Sorting numbers Zen Mozaic EZ 00= Hi, I have a Creative Zen Mozaic EZ 00, and I use this player primary for <span class="Apple"><span class="Apple">Audiobook.
    <span class="Apple"><span class="Apple">I have a problem when I transfer more than book to my player.
    <span class="Apple"><span class="Apple">?
    <span class="Apple"><span class="Apple">When I use the Albums, alle the files are not sorted, why isn't is sorted using the filename.
    <span class="Apple"><span class="Apple">?
    <span class="Apple"><span class="Apple">The only solution I have found, is using all tracks, here the files are sorted in filename order.
    <span class="Apple"><span class="Apple">?
    <span class="Apple"><span class="Apple">How do I sort the files in folders or Albums.
    <span class="Apple"><span class="Apple">?
    <span class="Apple"><span class="Apple">Kind regards,
    <span class="Apple"><span class="Apple">Kenneth

    Hi,
    Did you transfer the audiobook using Audible Manager?

  • How to find max value from a list of numbers stored in a varray?

    hi,
    Can any body help me to get the max value from a list of numbers stored in a varray?
    thanks in advance....
    regards
    LaxmiNarsimha

    Yes. Could you post what you have tried before we start helping you in this?

  • TS4147 I have my phone numbers stored in contacts but when I go to type a message in messages I get all the contacts I have deleated plus my partners contacts to ?....

    I have my phone numbers stored in contacts but when I go to type a message in messages I get all the contacts I have deleated plus my partners contacts to ?....

    Deleted information or previously used information (your partners) does not get "shredded/destroyed" but placed in storage/cache in order to be overwritten when space is necessary for the device. Since size of those contacts files is very insignificant, that overwrite takes very long time. The only way to completely get rid of that info is to go through complete erase/restore of the phone. All other data will be lost and have to be restored back the way that will not bring cache back. Essentially - no restore from the backup.

  • Numbers in varchar2 variable

    Dear friends,
    i have case like the following example, and i hope you have solution for my problem, lets assume the following:
    declare
    xx varchar2(10);
    begin
    xx := 5 ||','||6;
    select * from emp where emp_no in (xx);
    end ;
    when you run above query it will give invalid number. as the query didn't recognized the numbers inside the variable.
    Thanks in advance

    You want something like this:
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2  from emp
      3  where ename in (
      4    with t as (select '&input_string' as txt from dual)
      5    select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
      6    from t
      7    connect by level <= length(regexp_replace(txt,'[^,]*'))+1
      8*   )
    SQL> /
    Enter value for input_string: SCOTT,JAMES
    old   4:   with t as (select '&input_string' as txt from dual)
    new   4:   with t as (select 'SCOTT,JAMES' as txt from dual)
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 19-04-1987 00:00:00       3000                    20
          7900 JAMES      CLERK           7698 03-12-1981 00:00:00        950                    30
    SQL>Which would also work if the input was numbers and you were comparing against e.g. the empno column.

  • Storing numbers in char variables.

    Hi All
    I need to store a number in a character variable
    Num =  686  (integer type)
    here c1 is the char variable of length 4.
    If I give C1 =  Num
    the value is not stored.
    How to store a number in a character variable.
    Regards
    Renuka.

    Works fine. run the code below.
    REPORT  ztest.
    DATA: n TYPE i VALUE '6666',
          c TYPE char4.
    c = n.
    BREAK-POINT.
    write: c , n.

  • How to execute a select query stored in variable

    Hello  helpers ,
    I have some "select queries" stored in the database . Now I can derive this query in some variable . How do I execute this query from the variable .
    example :
    Data Query type char50 .
    QueryVar = 'Select MATNR from MBEW where BWKEY = '0001' . '
    How do I execute this Query stoored in variable QueryVar in ABAP program ?
    Thanks a lot for helping .
    Regards
    Shashank

    Shashank,
    It is also possible to use (column_syntax) and (dbtab_syntax) together with (cond_syntax) when using SELECT statements in ABAP. For more info on (column_syntax) and (dbtab_syntax) just have a quick look at ABAP Keyword documention on SELECT statement (hit F1 on SELECT then scroll down to Select->Select result->Select Columns....)
    So in your case, you need to separate out (split) the value in 'wa_itab-query' into other variables or append into separate internal tables using common keys etc. - then looping at those tables with the common key (READ TABLE WITH KEY....) use the following syntax at the time of triggering the SELECT query:
    SELECT (column_syntax)
           FROM (dbtab_syntax)
           WHERE (cond_syntax).
    Also worth a look at this example below:
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    DATA: column_syntax TYPE string,
          dbtab_syntax TYPE string.
    column_syntax = `c~carrname p~connid f~fldate`.
    dbtab_syntax = `( ( scarr AS c `
      & ` INNER JOIN spfli AS p ON p~carrid  = c~carrid`
      & ` AND p~cityfrom = p_cityfr`
      & ` AND p~cityto   = p_cityto )`
      & ` INNER JOIN sflight AS f ON f~carrid = p~carrid `
      & ` AND f~connid = p~connid )`.
    SELECT (column_syntax)
           FROM (dbtab_syntax)
           INTO CORRESPONDING FIELDS OF TABLE itab.
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Hope this helps.
    Cheers,
    Sougata.

  • Adobe Combine Feature - Sorts numbered files incorrectly

    At my company we use a scanning software called Kofax. We also have copies of Adobe Acrobat Standard 6-9 depending on how old the work station is.
    Lets say I scan a batch of 120 pages. It will scan each page as an individual .tif file and put them all in a folder.
    The naming convention for each page is:
    1.tif
    2.tif
    3.tif
    etc
    etc
    Windows explorer sorts these numbers in correct order. If I decide to select all 120 pages I just scanned, right click, Combine into PDF, it will place the pages in the following order.
    1.tif
    10.tif
    11.tif
    12.tif
    etc etc
    100.tif
    101.tif
    etc etc
    2.tif
    20.tif
    21.tif
    etc etc
    This basically requires me to resort the entire batch in the Adobe combine screen. This is very time consuming and tedious. Is there any way to get the Adobe software to recognize the "human" numbers in ascended order? Any help with this would be GREATLY appreciated.

    This involves using a photoeditor with renaming capabilities such as ACDSee OR using the command-line (Run>cmd.exe) from the Start menu.  For the command line you would type "help for" and a help file for the "for" command would come up.  With "for" you can run an iterative loop that would cycle through your files based on certain characteristics and based on the variables you pass it you would be able to renumber your files from 1.tif to 001.tif and 10.tif to 010.tif for example.  Numbers 1-9 would be in one for loop, numbers 10-99 would be in another, and if you had to rename for files going into the thousands you would use 100-999 as another for loop, renumbering to a 0100.tif naming convention.  That is called "padding" your file names.

  • How To: Sort Numbers in Ascending Order in a Generated List

    Greetings! How do I set up a Generated List of Paragraphs so that it sorts in true ascending order? What I want is:
    1.1
    1.2
    1.3
    1.4
    1.5
    1.6
    1.7
    1.8
    1.9
    1.10
    I have tried every trick I can think of with the sort order listed on the reference page. But all I can get is something that sorts by individual number (ignoring the numeric value) like:
    1.1
    1.10
    1.11
    1.2
    1.20
    1.21
    1.3
    Any help is much appreciated!

    Hello there, Michael! Thanks so much for looking at my post! Alas, the LOP will not work. I should have explained more, but it was so complicated I thought folks would give up reading.
    Here's the best I can render it without getting permission to share a good example document. I do not blame anyone if it's too cumbersome or convoluted to wade through...
    This is a requirements document which has sort of a "legal" tinge to it--as the document evolves we must maintain traceability for individual requirements. This means, for example:
    Version 1 - I have requirements 1 and 2.
    Version 2 - I need to add a new requirement, which should appear before requirement 1 in the document. Even though it comes before requirement 1 in the document, numerically it will be requirement 3 and requirement 1 will remain requirement 1.
    Version 3 - I need to remove requirement 2. Even though I now have only 2 requirements, their numbers will not change (they remain requirements 1 and 3, appearing in reverse order).
    Version 4 - I need to move requirement 3 to be after requirement 1. Again, the requirements keep their original number, even though their position has changed and there is no longer a "requirement 2" number in use.
    Originally, I told the team (I'm doing this for a different dept), that they would have to hand-number requirements, which they did for a while. But that was getting very cumbersome, and the scenarios above are limited to one or two occurrences per document. So I created an auto-number sequence for them to use in the initial version and added a little smoke-and-mirrors work process to take care of changes in later versions. The last bit of chicanery I cannot get to work is the index...
    Even if there are no changes to the requirements after the initial version, the index still does not sort in ascending numeric order. It was working with the hand-numbered requirements because they were using leading zeros. But without being able to include leading zeros in the auto-numbering formats (I tried the "use a zero as a tab leader" solution and like to have thrown my new monitor out of the window), I cannot find a solution.
    Or rather, I think the solution is "you have to hand-number requirements".
    For anyone who has made it this far, I truly appreciate your time and patience!
    SFT

  • Contract Generation question: Formatting, Numbering of clauses, variables

    Hi!
    I am trying to create a Contract Document Template (for Contract Generation) with Variables
    I created some Variable Collections, but when I link them to the Contract Template, they add on with a different formatting altogether, which is neither like the placeholder in the template nor like the template attached to the variable.
    My variable configuration was of the type Paragraph.
    If anyone has any helpful tips on formatting Contract Document Templates, it would be most appreciated.
    Also, how do I ensure that numbering of sections and clauses is sequentially made in the final Contract.
    Regards,
    Reshma

    I was able to fix the problem by making some word document format changes.
    Please ignore this question.
    Regards,
    Reshma

Maybe you are looking for