Arrays

The Arrays tools collection contains several useful functions for handling arrays. Most of them you surely already know and use but in case you are interested in:

or looking up values quickly, then have a look.

The Array sorting routines implement the Shell Sort Algorithm. Since I have seen dozens of different implementations of it I am not sure if it is Shell Sort or something else - anyhow, it is fast. You can use the Array Sort Test Utility in order to compare

Unfortunately, I have lost the source of the code. Nevertheless, you will find implementations for String Arrays or Arrays containing Long values or Double values. Additionally, you will find solutions for sorting multi dimensional Arrays.

The Array Lookup routines prefer using the Binary Search and you will find solutions for Arrays of String, Long or Double. Again, solutions are given for multi dimensioned Arrays, too. For the sake of completeness, solutions for Sequential Searchs are given as well.

Note:
The comments for BinarySearch state that the Array has to consist of unique values. This is true. Sometimes BinarySearch might find a value within the Array but it will not necessarily be the first value. But sometimes it will miss the searched value at all and not find any value. In order to reliably search an Array containing identical values you have to use a sequential search.

All Sort and Search Functions are given as strongly typed versions, too. This is of interest for you in case data of your arrays could be interpreted wrong by the VBE (which might happen in case you read the comparison value from a text box, etc.). In order to be on the sure side use the strongly typed solutions.

Credits: -

Download Demo Project:
Download
ArrayTools.zip