import random as rd

def Shell(arr):
    N = len(arr)
    n = N // 2
    while n>0:
        for i in range (0,N-n):
            j=i
            while j+n<N:
                if arr[j]>arr[j+n]:
                    t=arr[j]
                    arr[j]=arr[j+n]
                    arr[j+n]=t
                    j=i
                else:
                    j+=n
        n=n//2
    return arr

def records():
    phones=[]
    first=0
    second=0
    third=0
    fourth=0
    for i in range(10000):
        phones.append(str(first)+str(second)+str(third)+str(fourth))
        fourth+=1
        if fourth==10:
            third+=1
            fourth=0
        if third==10:
            second+=1
            third=0
        if second==10:
            first+=1
            second=0
    phones2=phones.copy()
    
    f=open("names.txt","r")
    count=0
    names=[]
    while count<5000:
        name=f.readline()
        names.append(name[:len(name)-1])
        names.append(name[:len(name)-1])
        count+=1
    f.close()
    
    names_sorted=names.copy()
    for i in range(10000):
        names_sorted[i]=names_sorted[i].encode()
    Shell(names_sorted)
    for i in range(10000):
        names_sorted[i]=names_sorted[i].decode()
    
    records_shuffled=[]
    records_sorted=[]
    count=0
    while count<10000:
        name_var=rd.randint(0,len(names)-1)
        phone_var=rd.randint(0,len(phones2)-1)
        records_shuffled.append((names[name_var],phones[count]))
        records_sorted.append((names_sorted[count],phones2[phone_var]))
        names.remove(names[name_var])
        phones2.remove(phones2[phone_var])
        count+=1
        
    rd.shuffle(records_shuffled)
    return records_shuffled, records_sorted
#print(records_shuffled)
#print(records_sorted)

