Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently October 12th, 2024, 7:20 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Ordering numbers
PostPosted: May 17th, 2006, 5:42 pm 
Offline

Joined: June 10th, 2005, 11:35 am
Posts: 5
Location: Coulsdon, Surrey
Hi
Am trying to write a script which will order 5 numbers highest to lowest.
Happily using Math.max and Math.min to get the highest & lowest values but have hit a blank about how to order the 3 others in the middle.

Does anyone know of a prewritten function that i can use to do this or if anyone has any other ideas i would be grateful as i've now spent 3 hours on this and am no further forward. Aaargh!

Looking forward to all/ any replies

Thanks
Dawn


Top
 Profile  
 
 Post subject:
PostPosted: May 17th, 2006, 8:58 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Hi Dawn,
Basically, to get a row of numbers in order -- you load the numbers into an array then run a numerical sort.
See attached pub -- has a simple bubble sort.

Don't use the simpler looking array sort() function or sort a string,
you will get an alphabetical sort and numbers like 11 will be placed before 2.

cheers
Paul


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group