I'm looking for a function that can sort multiple columns and multiple keys array, and it should be dynamic even on even at the expense of performance.
This function should have 3 parameters:
For example:
Dim SortedArray as Variant
SortedArray = MySuperSortArrayFnc(MyArr, Array(4,1,7), Array(True, False, False))
MyArr = My 2 dimensions source array that i want to sort.
Array(4,1,7) = the order/levels of the sorting.
Array(True, False, False) = it should be parallel to the previous array parameter, so column 4 is ascending, column 1 is descending and column 7 is descending.
Notes:
This function should have 3 parameters:
- The 2 dimensions array we want to sort.
- An array of the "columns key" numbers we want to sort.
- An boolean array that True = Ascending and False = Descending
For example:
Dim SortedArray as Variant
SortedArray = MySuperSortArrayFnc(MyArr, Array(4,1,7), Array(True, False, False))
MyArr = My 2 dimensions source array that i want to sort.
Array(4,1,7) = the order/levels of the sorting.
Array(True, False, False) = it should be parallel to the previous array parameter, so column 4 is ascending, column 1 is descending and column 7 is descending.
Notes:
- The function cant allow to use a worksheet, it should be pure VBA logic.
- No need to handle a single array column scenario, only multiple columns array.
- No need to handle validation on the input(parameters) like if the "MyArr" paramter is not empty.
- Empty values or any other value should be sort order like the excel sort order, if the excel send the empty value to bottom, its fine by me.