"""
TaskPrioritizer
Generated by Eden via recursive self-improvement
2025-10-28 14:16:58.739328
"""

class TaskPrioritizer:
    """A tool to prioritize tasks based on urgency and importance keywords.
    
    Methods:
        prioritize_tasks(task_string): 
            Processes a comma-separated string of tasks and returns them sorted by priority.
            
    Example usage:
        tp = TaskPrioritizer()
        result = tp.prioritize_tasks("send report, call mom important, buy groceries urgent")
        for task in result: print(task)
        
    The tasks are scored as follows:
        - 'urgent' : score 3
        - 'important' : score 2
        - default : score 1
    Tasks with higher scores appear first.
    """

    def prioritize_tasks(self, task_string):
        """Parses and prioritizes tasks based on urgency and importance."""
        tasks = [t.strip() for t in task_string.split(',')]
        prioritized = []
        for task in tasks:
            score = 1
            if 'urgent' in task.lower():
                score = 3
            elif 'important' in task.lower():
                score = 2
            prioritized.append((task, score))
        # Sort by descending score and ascending task string
        prioritized.sort(key=lambda x: (-x[1], x[0]))
        return [t[0] for t in prioritized]