         }
     }
     
+    // MARK: Outlets
+    
     @IBOutlet private weak var sortOrderPopupButton: NSPopUpButton?
     @IBOutlet private weak var filterPopupButton: NSPopUpButton?
+    
+    // MARK: Initial Configuration
     
     override func viewDidLoad() {
         super.viewDidLoad()


class SortSelectingViewController: NSViewController {
    
    weak var delegate: URLItemsToLoadChangeDelegate?
    
    private var _filter: URLItem.ArchiveFilter = .all
    var filter: URLItem.ArchiveFilter {
        get {
            guard
                let button = self.filterPopupButton,
                let selection = URLItem.ArchiveFilter(rawValue: button.selectedItem?.tag ?? 55)
            else { return self._filter }
            return selection
        }
        set {
            self._filter = newValue

        }
    }
    
    // MARK: Extract Info from UI
    
    private func filterFromUI() -> URLItem.ArchiveFilter? {
        guard
            let button = self.filterPopupButton,
            let selection = URLItem.ArchiveFilter(rawValue: button.selectedItem?.tag ?? 55)
        else { return .none }
        return selection
    }
    
    private func sortOrderFromUI() -> URLItem.SortOrder? {
        guard
            let button = self.sortOrderPopupButton,
            let selection = URLItem.SortOrder(rawValue: button.selectedItem?.tag ?? 55)
        else { return .none }
        return selection
    }
    
    // MARK: Respond to User Actions
    
    @IBAction private func sortOrderChosen(_ sender: NSObject?) {
        // check if the new selection is different before notifying the delegate
        guard let newValue = self.sortOrderFromUI(), newValue != _sortOrder else { return }
        _sortOrder = newValue
        self.delegate?.didChange(itemsToLoad: .none, sortOrder: self.sortOrder, filter: .none, sender: .tertiaryVC)
    }
    
    @IBAction func filterChosen(_ sender: NSObject?) {
        // check if the new selection is different before notifying the delegate
        guard let newValue = self.filterFromUI(), newValue != _filter else { return }
        _filter = newValue
        self.delegate?.didChange(itemsToLoad: .none, sortOrder: .none, filter: self.filter, sender: .tertiaryVC)
    }
}
