Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Sorting number with keep original index (https://www.askmehelpdesk.com/showthread.php?t=709159)

  • Oct 15, 2012, 05:59 AM
    andewors
    Sorting number with keep original index
    I made this code to loop number

    Code:

    for(int i=0;i<4;i++){
        double temp[i]=Math.random() * i*10;
        system.out.println("Result" +i+ "=>" +temp);
    }

    output :

    Code:

    Result 1 => 14.3
    Result 2 => 11.4
    Result 3 => 10.8
    Result 4 => 12.4

    now, how to shorting this output based on value with keep original index, so the output like this :

    Code:

    Result 3 => 10.8 => Grade 1
    Result 2 => 11.4 => Grade 2
    Result 4 => 12.4 => Grade 3
    Result 1 => 14.3 => Grade 4

    how to do this?? I need your help

  • All times are GMT -7. The time now is 11:55 AM.