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.

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Start your 7-day free trial
The above is a quicksort. This one is a bubblesort (for smaller arrays)
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.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

sadupopsAuthor Commented:
above solution wrong
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.
sadupopsAuthor 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, _
        Default:=ActiveCell.Address, _
        Type:=8) 'Range selection
            If UserRan Is Nothing Then
        MsgBox "Canceled."
        GetUserRange UserRan.Range("A1:A2:A3") '= Output
    End If

i am trying to write a VB code that will ask the user to enter the columns in which he wants processed. in the form of A1:B1:C1 or A:B:C. is this possible? if so how can it be done. and after the user has entered it. i want to store them in an array. so that the first index of the array will have lets say "A", the second index "B" and so on.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.