The ordered isomorphs of Planet Linear Chaos love to sort and accept into their ranks those who are proficient at sorting. What's that you say? You don't plan on associating with them? That won't work: isomorphs are often the ones conducting interviews at IT companies. We won't ignore them: write a program that reads 20 numbers from the keyboard and displays them in decreasing order.
In decreasing order
You must be signed in to leave a comment
26 April 2021, 15:57
This task was like task 0622. It can be done with a simple Collection, but it was good to do it with nested loops, to understand the logic behind it. I didn't understand the logic behind int j = i at first, but when I wrote it out, I understood it. Fun exercise! Happy coding :)
4 March 2021, 21:16
Change int to Integer. Use collections reverse sort. Done. This won't be acceptable solution according to the requirements (since they want int, not Integer), but who cares. Problem solved without unnecessary complications like nested loops.
24 January 2020, 20:57
My code works, and it verifies correctly, but I am still confused. The sort method is void. It is not returning anything. So how is the sorted array being printed in the correct decreasing order?
4 April 2020, 14:02
Yeah, I don't get it either. I expected to have to print it out in the sort method.
25 April 2020, 08:24
the sort method is void, so it doesn't have a data type to return. when we call the function "sort(array)" we pass it a copy of the array and the code in that method changes the array's 'internal state' (sorts it in descending order).
28 April 2020, 13:16
Thanks, that clears it up for me.
29 April 2020, 00:42
remember when we use array its a reference point to an object, so whenever we touch that same object in different methods, what is in the array will change.
31 October 2020, 20:25
this will explain what is going on https://books.trinket.io/thinkjava2/chapter7.html
Kent Hervey Software Engineer/Consult at Zeal IT Consultants
25 November 2019, 05:06
It is still frustrating when I meet what I think are the requirements, but does not verify. I used collections sort then reversed. codegym did not like that. wants me to make my own sorting algorithm...so I did that and it passed. Okay because I learned two ways to do it.
17 September 2019, 09:25
why ? i think i'm right. plz help me
14 July 2019, 15:35
Wait we can use the names sorting algorithms?
4 February 2019, 11:47
Hint: Bubble Sort