def rangeSearch(datb, keyS, keyE):
    """Retrieve records with a given range of key values
    Keyword arguments:
    datb -- the database.
    keyS -- starting key.
    keyE -- ending key.
    Returns a list of key/data pair within the range, inclusive.
    """    
    rangeFind = list()
    cur = datb.cursor()
    
    if datb.get_type() == 2:
        #puts cursor to last place and gets its data
        ends = cur.last()
        #Puts cursor back to the first place gets its data, starting the search from here now.
        z = cur.first()
        
        while(True):
            if (z[0] <= keyE and z[0] >= keyS):
                rangeFind.append(z)
            
            z = cur.next()
            
            if(z == ends):
                break;
        #expensive tooo??? might do it outside this function?:
        #rangeFind.sort()
            
    elif datb.get_type() == 1:
        z = cur.set_range(keyS)
        
        while(z[0] <= keyE):
            rangeFind.append(z)
            z = cur.next()
        
    cur.close()
    return rangeFind