# Sorting an array based on its index

i have this code

Function Coo(ParamArray dat1() As Variant) As Variant

Dim intI As Integer
For intI = 0 To UBound(dat1())
'For i = 1 To Range.Cells.Count
If dat1(intI) Then
Coo = dat1(intI)
End If
Next intI
End Function

now am trying to write a function that takes a certain number of parameters into an array. lets say this
we have a certain number of columns
col A       col B      col C
1                        8
2                        9
3            5
4            3           0

now the function takes in 3 columns or cells. what i am trying to do is sort the cells/columns in the order of priority and put the sorted items into another column. for example col A has 1, col B has nothing, and col C has 8. since col C has higher priority (assuming the order of priority is C, B, A) 8 will be kept in the sorted column. what am trying to do is write a function that will take an infinite amount of columns or at least 2. any help ????????? or suggestions ???????
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
The above is a quicksort. This one is a bubblesort (for smaller arrays)
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21449337.html
Commented:
Sorry, the second one only sorts on one column. The way to sort several columns is to sort the array by one column at a time. Each iteration you take the results of the previous sort and sort that. You should start by sorting the least most significant column and then sort the results by the next least significant, take the results and sort them by the next least significant column etc. Finally sorting on the most significant column.
Author Commented:
above solution wrong
Commented:
In what way? Wich bit is wrong. Can I have some feedback?
Is it that you don't want to sort an array at all, but excel columns. Sorry, I wasn't paying attention and didn't initially realise this was an excel problem. I thought it was should have read the question better and not read the the title.
Author Commented:
Sub GetUserRan()
Dim UserRan As Range
Dim nput As Variant
Dim Prompt As String
Dim Title As String

Prompt = "Select a cell for the input."
Title = "Select a cell"

'   Display the Input Box
On Error Resume Next
Set UserRan = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _