I have a script that at the moment checks a filename against excel rows.
It gets the filename and then scans column 1 to see if that filename exist if it does ten it moves the file.
Quite simple really. But…
The excel sheet is sort alphabetically and uses letters. What i would like to do is do a binary search as this would be alot quicker.
For those who dont know a binary search goes half way through the list it then sees if the value you have is either higher or lower than the current item. If higher then it goes to the next half, which would be the 3rd quarter mark. Does the same search. It stops when it reaches a point where the current item is equal to the search string.
Example, using numbers:
5 < looking for 5 in a list of 1 - 20
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
On first step:
get half way point 10.
Is 5 < current item if yes get next point (half of 10)
Is 5 = current item, yes then there is the search co,mplete.
As you can see this is alot faster, only 2 checks and not 5.
Does anyone know how to do this??? Baring in mind i use an excel sheet, but i would be able to put it in a text document sorted if that would be easier.