Esempio n. 1
0
# extract only the id and add the tuple to dictionary
base_list = []
base_dict = {}
for row in result:
    base_list.append(row[0])
    base_dict[row[0]] = row

## get search key from user
pid = int(input("\n\tEnter searching id? "))

print("\n\tPlease Wait! Searching data....")
start_time = time.clock()

## first sorting using radix sort
radix = RadixSorting(base_list, 0)  # 0 - sort by id
radix.sort_id()
result = radix.result

search_result = binary_search(result,
                              pid)  # returns pid if found else returns False
end_time = time.clock() - start_time

if search_result:
    _person.display_query_result([
        base_dict[search_result]
    ])  # fetch the row of the id using base dict created earlier
else:
    print("\n\tNo result found!")

print("\nCPU clock time spent:", end_time)
Esempio n. 2
0
    
    if sort_by == 1:
        radix.sort_name()
    elif sort_by in [2,4,7,10]:
        radix.sort_email_bio_address_media()
    elif sort_by == 3:
        radix.sort_phone()
    elif sort_by == 5:
       radix.sort_dob()
    elif sort_by == 6:
        radix.sort_gender()
    elif sort_by in [8,9]:
        radix.sort_long_lat()
    
    
    sorted_list = radix.result
    # re-arrange the rows based on the sorted list
    for i in range(len(sorted_list)):
        result[i] = base_dict[sorted_list[i][0]]

    end_time = time.clock()-start_time

_person.display_query_result(result)
# _person.display_query_result([result[0]])
# _person.display_query_result([result[-1]])

# for row in result:
#     print(row[sort_by])

print("\nCPU clock time spent:", end_time)