def search(qry)
      rg = Regexp.new(qry || '', Regexp::IGNORECASE)

      # Flatten to an array with [email1, name1, email2, name2] etc.
      results = @addresses.values.flatten.each_slice(2).find_all do |e, n|
        e.match(rg) || n.match(rg)
      end

      # Sort by case-insensitive email address
      results.sort { |a, b| a[0].downcase <=> b[0].downcase }
    end
def search(qry)
      rg = Regexp.new(qry || '', Regexp::IGNORECASE)

      # Flatten to an array with [email1, name1, email2, name2] etc.
      results = @addresses.values.flatten.each_slice(2).find_all do |e, n|
        e.match(rg) || n.match(rg)
      end

      # Sort by case-insensitive email address
      results.sort { |a, b| a[0].downcase <=> b[0].downcase }
    end
Retrieves name and email addresses that contain the passed string sorted
 by email adddress

 @param qry [String] search string

 @return [[[String, String]]] Array of email addresses and names found.
   Each element consists of a 2 element array. The first is the email
   address and the second is the name

 @example
   cache.search("smi") #=>
     [["e1@acompany.com", "Mr Smith"], ["e2@bsomewhere.com", "Mr Smith"]]