diff options
author | benal01 <bja4245@rit.edu> | 2025-03-30 00:46:50 -0400 |
---|---|---|
committer | benal01 <bja4245@rit.edu> | 2025-03-30 00:46:50 -0400 |
commit | 760b8efef4d683d26404ebca75b7a9c44a1db3a9 (patch) | |
tree | 0d13fe8cc3907dd1f926757b39657f4efc24a206 /ufund-ui/src/app/components/need-list | |
parent | daae556a1be7a30bc6f4606bd1b1567b713d054a (diff) | |
download | JellySolutions-760b8efef4d683d26404ebca75b7a9c44a1db3a9.tar.gz JellySolutions-760b8efef4d683d26404ebca75b7a9c44a1db3a9.tar.bz2 JellySolutions-760b8efef4d683d26404ebca75b7a9c44a1db3a9.zip |
urgency sorting
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 16 |
1 files changed, 13 insertions, 3 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 37a3775..4ae8f4a 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 sortByPriority: sortAlgo = (a: Need, b: Need): number => { + if(a.urgent == b.urgent) { + return sortByGoal(a,b); + } + else if(a.urgent && !b.urgent) { + return -1; + } + return 1; +} + @Component({ selector: 'app-need-list', standalone: false, @@ -38,13 +48,13 @@ export class NeedListComponent { searchResults: Need[] = []; sortMode = 'Ascending' - currentSortAlgo: sortAlgo = sortByName; - sortSelection: string = 'sortByName'; + currentSortAlgo: sortAlgo = sortByPriority; + sortSelection: string = 'sortByPriority'; SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [ {func:sortByName,name:"sortByName", display:["Name (Alphabetical)", "Name (Reverse)"]}, {func:sortByGoal,name:"sortByGoal", display:["Largest Maximum Goal", "Smallest Maximum Goal"]}, - {func:sortByName,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]}, + {func:sortByPriority,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]}, ]; @Output() currentNeed = new EventEmitter<Need>(); |