hongrich / milkthecow

Automatically exported from code.google.com/p/milkthecow
0 stars 0 forks source link

patch to sort beyond just dates #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. just look at your list of tasks
2. note that it only sorts on date.. otherwise, there's no ordering thereafter

What is the expected output? What do you see instead?

it would be nice to see it sort on priority, then (optionally) the names
(alphabetically)

What version of Milk the Cow are you using? On which version of OS X?

0.4.4 on leopard

Please provide any additional information below.

here's a patch with what i'm currently running:

------------------startpatch
--- milkthecow.js.044   2009-05-07 16:46:17.000000000 -0700
+++ milkthecow.js   2009-05-07 16:52:21.000000000 -0700
@@ -779,9 +779,21 @@
    }
 }

+// compares prioritiies
+function comparePriority(a, b){
+   a = (a == "N") ? 4: a;
+   b = (b == "N") ? 4: b;
+   return a - b;
+}
+// compares strings
+function compareString(a, b){
+   if (a == b) return 0;
+   return (a < b) ? -1 : 1;
+}
+
 //helper function to sort array of Dates
 function sortTasks (t1, t2){
-   return t1.date-t2.date;
+   return t1.date-t2.date || comparePriority(t1.task.priority,
t2.task.priority) || compareString(t1.name, t2.name);
 }

 //add a task when return or enter is pressed
------------------endpatch

Original issue reported on code.google.com by jin.y...@gmail.com on 7 May 2009 at 11:58

GoogleCodeExporter commented 9 years ago
patch applied in r114

Thanks for submitting this patch

Original comment by hong.rich on 8 May 2009 at 1:39