If the array is kept sorted, for some appropriate comparison operator, then searches for keys in that array are all O(log N). Hash lookups are also typically logarithmic, so it seems that array + binary search would do what you want: reorder the array as needed while still locating keys with good efficiency.