'Sort notifications by priority into output_dict.'

def _SortByPriority(self, notifications, queue, output_dict=None):

    if (output_dict is None):
        output_dict = {}
    for notification in notifications:
        priority = notification.priority
        if notification.in_progress:
            priority = self.STUCK_PRIORITY
        output_dict.setdefault(priority, []).append(notification)
    for priority in output_dict:
        stats.STATS.SetGaugeValue('notification_queue_count', len(output_dict[priority]), fields=[queue.Basename(), str(priority)])
        random.shuffle(output_dict[priority])
    return output_dict
