Implement a custom sorting mechanism for a stream of incoming real-time alerts based on priority and timestamp.
Implement sort_alerts(alerts), where alerts is a list of dictionaries with integer priority and timestamp fields. Return the alert dictionaries ordered by descending priority, then ascending timestamp. Preserve arrival order when both fields are equal.
def sort_alerts(alerts):