Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sorting  RSS feed

 
terry oliver
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the best way to sort three double variables in ascending order

thanks Olly
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what your definition of best is. Also, you must consider what to do when any of the doubles is NaN - that will not compare to anything.

Fast method:

There is a more generic method however, for any number of (non-NaN) numbers:
 
arulk pillai
Author
Ranch Hand
Posts: 3404
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I think I got lucky on a few questions though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!