Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dESCENDING ORDER

 
priyanshu bhardwaj
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give me the logic to program such taht a array is sorted in descending order
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
but is there a function like sort in java
thanks for telling
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a class called Arrays that has methods that will sort array of numbers.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
priyanshu bhardwaj
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
I'll see the API
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic