Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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: 21044
85
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: 3413
 
Rob Spoor
Sheriff
Posts: 21044
85
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!