I need to sort and array from highest to samllest, puting those values into a ne
ID: 3624528 • Letter: I
Question
I need to sort and array from highest to samllest, puting those values into a new arrayint []array1 = {1,2,3,4};
int [] arraynew = new int [4]; //want to put the organized values in this array
This is what i have so far
int max = array1[0];
for (int i = 1; i <array1.length; i++){
if (array1[i] > max){
max = array1[i];
array1new[0]= max; // put the highest found element from
{ (//break???idk//) // array1 into arraynew [0]
{
I dont know what to do next, if i search array1 again i will encounter the same number i just put into arraynew[0]; How do i account for this?
Explanation / Answer
Compare elements 1 and 2, get higehst number and put in in index 1, then compare element 2 and 3, put hightest num. in index 2 and so on. You are STUPID!!