order 10 numbers

1. Corin Guest

## order 10 numbers

I have a group of random numbers, what&#039s the fastest ASP code to get them in numeric order?<BR><BR>Thanks in Advance

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: order 10 numbers

For only 10 numbers, a bubble sort is surely adequate.<BR><BR>Assuming the 10 numbers are in an array:<BR><BR>&#060;%<BR>nums = Array( 103, 999, 12, 301, 444, 812, 321, 123, 98, 701 )<BR><BR>For i = UBound(nums) To 1 Step -1<BR>&nbsp;&nbsp;&nbsp;&nbsp;For j = 1 To i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;If nums(j-1) &#062; nums(j) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp = nums(j)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nums(j) = nums(j-1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;nums(j-1) = temp<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;Next<BR>Next<BR>%&#0 62;<BR><BR>That&#039s not fastest, perhaps, but it&#039s about the simplest.<BR><BR>Of course, the very fastest would be to use JavaScript, because JS has a built-in function that sorts arrays for you.<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•