This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes dESCENDING ORDER Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "dESCENDING ORDER" Watch "dESCENDING ORDER" New topic
Author

dESCENDING ORDER

priyanshu bhardwaj
Greenhorn

Joined: Jul 30, 2005
Posts: 20
Please give me the logic to program such taht a array is sorted in descending order
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
If the array is an array of numerics, then you could multiply each element by -1, call sort, and then multiply each element by -1.
priyanshu bhardwaj
Greenhorn

Joined: Jul 30, 2005
Posts: 20
Thanks
but is there a function like sort in java
thanks for telling
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
There is a class called Arrays that has methods that will sort array of numbers.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Do you mean you need to implement a sorting algorithm? Or can you use the built-in sort methods from the Java API? If you are interested in using the API, look at the java.util.Arrays class in the documentation (see the link in my signature). You may also want to use the reverseOrder() method from the java.util.Collections class.

What have you tried so far? Please give some details so that we can help you.

Layne
[ January 21, 2006: Message edited by: Layne Lund ]

Java API Documentation
The Java Tutorial
priyanshu bhardwaj
Greenhorn

Joined: Jul 30, 2005
Posts: 20
Thanks
I'll see the API
 
GeeCON Prague 2014
 
subject: dESCENDING ORDER