diff options
Diffstat (limited to 'ufund-ui/src')
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 4ae8f4a..17bb3e6 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -26,6 +26,16 @@ const sortByGoal: sortAlgo = (a: Need, b: Need): number => { return 1; } +const sortByCompletion: sortAlgo = (a: Need, b: Need): number => { + if(a.current == b.current) { + return sortByGoal(a,b); + } + else if(a.current > b.current) { + return -1; + } + return 1; +} + const sortByPriority: sortAlgo = (a: Need, b: Need): number => { if(a.urgent == b.urgent) { return sortByGoal(a,b); @@ -52,8 +62,9 @@ export class NeedListComponent { sortSelection: string = 'sortByPriority'; SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [ - {func:sortByName,name:"sortByName", display:["Name (Alphabetical)", "Name (Reverse)"]}, + {func:sortByName,name:"sortByName", display:["Name (A to Z)", "Name (Z to A)"]}, {func:sortByGoal,name:"sortByGoal", display:["Largest Maximum Goal", "Smallest Maximum Goal"]}, + {func:sortByCompletion,name:"sortByCompletion", display:["Most Completed", "Least Completed"]}, {func:sortByPriority,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]}, ]; |