1. Member
Join Date
Dec 2013
Posts
1
Rep Power
0

## H>descending order

I am new here in this forums and i got a question.

Q:
Create a program that gets 10 random numbers from the user and inputs it in descending order.

Example output: Input 10 numbers: 50 69 10 29 11 12 30 40 80 22
Descending order: 80 69 50 40 30 29 22 12 11 10
--------------------------------------------------------------------------------------------------

can u help me with the logic code? i was thinking using arrays for this. thanks in advance.

2. ## Re: H>descending order

Are you working on code to sort an array of numbers?
What have you tried?

3. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
203
Rep Power
0

## Re: H>descending order

What I would do it have 2 String arrays of the same fixed size (10), I would go through the input array with a loop and use the Random library to select a random index and if that index has a value in it, set the output array in order and set the current index of the input array to null.

Edit: Before Norm or gimbal2 or anyone else comes in here and disproves my method: I chose a String array because OP could enter any value in his array from -2.147 billion to +2.147 billion so there is no open number to use as a place holder (i.e -1) with a String array, null is always an open placeholder (not "null", but null)
Last edited by zFollette; 12-24-2013 at 05:19 PM.

4. ## Re: H>descending order

Sounds like a confusion to me and way more complicated than doing a sort in a loop.

5. ## Re: H>descending order

Originally Posted by zFollette
I chose a String array because OP could enter any value in his array from -2.147 billion to +2.147 billion so there is no open number to use as a place holder (i.e -1) with a String array, null is always an open placeholder (not "null", but null)
Integer objects can be null too and it would save you the conversion to/from the String type; but the method is silly to start with: simply sort the thing with a suitable Comparator.

kind regards,

Jos

6. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
203
Rep Power
0

## Re: H>descending order

Originally Posted by JosAH
Integer objects can be null too and it would save you the conversion to/from the String type; but the method is silly to start with: simply sort the thing with a suitable Comparator.

kind regards,

Jos
Fair enough.