Tom van Stiphout wrote:

On Mon, 11 Jul 2005 22:47:26 -0400, "Indrid Colt" <in****@colt.co m>

wrote:

Well, you could use the Split function to create an array with 5

elements. Then use any suitable sorting algorithm to sort these items.

Then use the Join function to stitch the elements back together.

-Tom.

I am assuming you don't want to use ADO to put the items in a table for

Access to sort :-). Based on Tom's suggestion:

'Begin test code behind command button

Dim varList As Variant

Dim varOut As Variant

varList = Array("10", "2", "1")

varOut = SortMe(varList)

MsgBox ("varOut(0) = " & varOut(0))

MsgBox ("varOut(1) = " & varOut(1))

MsgBox ("varOut(2) = " & varOut(2))

'End test code behind command button

'Begin code behind the same form

Private Function SortMe(ByVal varArray As Variant) As Variant

Dim N As Integer

Dim I As Integer

Dim J As Integer

Dim FoundAt As Integer

Dim varMin As Variant

Dim varOutput As Variant

'Assuming the number of items is small, say < 100, an

'inefficient sort method such as one used by a card

'player (insertion sort) is adequate and easy to understand

varOutput = varArray

For N = UBound(varArray ) To 0 Step -1

varMin = varArray(0)

FoundAt = 0

For I = 1 To N

If varArray(I) < varMin Then

varMin = varArray(I)

FoundAt = I

End If

Next I

varOutput(UBoun d(varArray) - N) = varArray(FoundA t)

For J = FoundAt To N - 1

varArray(J) = varArray(J + 1)

Next J

Next N

SortMe = varOutput

End Function

'End code behind the same form

Output when the command button is clicked:

1 10 2

When varList = Array(10, 2, 1) the output becomes:

1 2 10

You can probably use the Split function to get the input string into

varList directly. The sort function works by finding the minimum from

the first N elements, placing it in the output, then sliding the array

elements down starting where the minimum was found, then decrementing N

by one. The time for this sort is proportional to the number of

elements squared. Test this code well before using.

James A. Fortune