I'm on dead end which I am no able to figure out even google up :(
Let's say I have this exemple (please do not comment that it might be better ways to create such an array, this is on purpose):
Dim someArray() As Variant: ReDim someArray(0 To 0)
ReDim Preserve someArray(0 To UBound(someArray) + 1): someArray(UBound(someArray)) = Array(6, CStr("text1"), CLng(5), CDbl(100))
ReDim Preserve someArray(0 To UBound(someArray) + 1): someArray(UBound(someArray)) = Array(6, CStr("text2"), CLng(3), CDbl(101))
ReDim Preserve someArray(0 To UBound(someArray) + 1): someArray(UBound(someArray)) = Array(6, CStr("text4"), CLng(2), CDbl(102))
ReDim Preserve someArray(0 To UBound(someArray) + 1): someArray(UBound(someArray)) = Array(6, CStr("text3"), CLng(1), CDbl(100))
and what I need is to fugure out the function to sort by two columns in the someArray() from (1 to UBound(someArray)) based on two colums I pass as arguments:
- so eather first sort by second column (1) which is CStr, and if records are the same then sort by third column (2)
- or which two columns I will set as arguments in the function to sort out
Unfortunately I am very lost here... only option which is realy terrible is to insert data into new sheet, let worksheet function to sort it accordingly, and reinsert into array, which is something i definitely do not wish to do :(
thank you for ideas...
I took your question as a challenge and found a way to pseudo sort the jagged array in the way you need. I mean, it will rearrange the jagged array arrays according to their second element, or according to the third one, if the second ones are in good order:
I let in the function (for instructional purpose) some commented lines, to offer the possibility to see what is the return of specific (joined) arrays...
Please, send some feedback after testing it.
If something not clear enough, please do not hesitate to ask for clarifications...