#!/usr/bin/env python3

import csv

def extract_and_sort_emails(input_csv, output_txt):
    email_list = []
    
    with open(input_csv, mode='r', newline='') as csvfile:
        csvreader = csv.reader(csvfile)
        for row in csvreader:
            # Extract the email address (assuming it's the third column)
            email = row[2]
            email_list.append(email)
    
    email_list.sort()
    
    with open(output_txt, mode='w') as txtfile:
        for email in email_list:
            txtfile.write(f"'{email}',\n")

if __name__ == "__main__":
    extract_and_sort_emails('input.csv', 'output.txt')
