Rearranging numbers in order
BlitzMax Forums/BlitzMax Programming/Rearranging numbers in order| 
 | ||
| Hello, folks. Say I had a list of 10 random numbers in an array. How do I put them in order? Many thanks. T. | 
| 
 | ||
| Local ARRAY:Int[10] For Local i:Int=0 Until 10 array[i]=Rand(1,100) Next For Local as:Int=EachIn array Print as Next array.sort Print "Ordered..." For as=EachIn array Print as Next | 
| 
 | ||
| Thanks, but I was trying to understand the concept behind it. Say the ARRAY.SORT command thing didn't exist - how would you code it then? T | 
| 
 | ||
| http://en.wikipedia.org/wiki/Sorting_algorithm | 
| 
 | ||
| Yah, look up sorting algorithms. A simple sort is a bubble sort but it is slow, something like a quicksort is better. | 
| 
 | ||
| Fantastic article. Just what I needed to know. Thank you, all. T | 
| 
 | ||
| Here is a link to some sorting algorithms.  They are in java, but easy to convert to BMax.  Each has an example on th epage that shows how it works. http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html |