Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / sorting numbers into order

Author
Message
ardeer
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location:
Posted: 18th Dec 2010 10:39
after selecting a list of random numbers how do i sort them into ascending order
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Dec 2010 10:57
Hi, you will need to create an array filled with the desired numbers. You will then need to sort the array, checking for which elements are larger than the others.

Here is a code snippet that demonstrates this but before jumping straight to the answer, have a go at coding it yourself



A clever person solves a problem, a wise person avoids it - Albert Einstein
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Dec 2010 14:36
Short answer: Use the SORT ARRAY commands in my plug-ins.

Long answer: This is one of those areas where I suggest that you learn and experiment with - Hodgey has shown you a bubblesort, you should look into some of the other sorting mechanisms available - in fact, I see a new one on the list that I don't know about...

PS. questions on sorts are pretty much guaranteed in programming interviews.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Dec 2010 14:34
If you don't have IanM's plugin I suggest you get it anyway (even if you don't get it for this). It will either save your sanity or save your life (depending on how frustrated you are feeling)... on a number of occasions... trust me

Login to post a reply

Server time is: 2024-09-29 00:22:25
Your offset time is: 2024-09-29 00:22:25