import csv

with open("data/country-and-continent.csv", "r") as countries:
    next(countries)
    records = countries.readlines();

sorted_data = sorted(records, key=lambda line: line[3])

print("First 10 entries, incorrectly sorted:")
for index in range(1,11):     
    print(sorted_data[index], end='')

print('-' * 60)

with open("data/country-and-continent.csv", "r") as countries2: 
    reader = csv.DictReader(countries2)
    sorted_list = sorted(reader, key=lambda row: row['Two_Letter_Country_Code'])


print("First 10 entries, correctly sorted:")
for index in range(1,11):     
    record = sorted_list[index]
    name = record['Country_Name']
    code = record['Two_Letter_Country_Code']
    print("{} => {}".format(code, name))
    
    
    