I have an array of perl tasks that looks like this:
@todos = ( "1 (A) Complete online final @evm4700 t:2010-06-02", "3 Write thank-you t:2010-06-10", "4 (B) Clean t:2010-05-30", "5 Donate to LSF t:2010-06-02", "6 (A) t:2010-05-30 Pick up dry cleaning", "2 (C) Call Chris Johnson t:2010-06-01" );
This first number is the identifier of the task. If a task has ([AZ]) nearby, this determines the priority of the task. What I want to do is sort the array of tasks in such a way as to put priority elements first (and in decreasing order of priority from A to Z):
@todos = ( "1 (A) Complete online final @evm4700 t:2010-06-02", "6 (A) t:2010-05-30 Pick up dry cleaning", "4 (B) Clean t:2010-05-30", "2 (C) Call Chris Johnson t:2010-06-01" "3 Write thank-you t:2010-06-10", "5 Donate to LSF t:2010-06-02", );
I can't use regular sort() because of these identifiers next to tasks, so I assume some sort of custom sort routine is needed. However, my knowledge of how to do this effectively in perl is minimal.
Thank you all.
sorting arrays perl
Abach
source share