aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/need-list/need-list.component.ts
diff options
context:
space:
mode:
authorAkash Keshav <112591754+domesticchores@users.noreply.github.com>2025-03-25 09:45:38 -0400
committerAkash Keshav <112591754+domesticchores@users.noreply.github.com>2025-03-25 09:45:38 -0400
commit07d191cb1fc8890f66e9af7d19e8276089d18d8b (patch)
treeb07a7581b6f53d1560091b8b42e66eac822e85cf /ufund-ui/src/app/components/need-list/need-list.component.ts
parent304b867c6fa5c1192e8cdec7fd22affb50e244b3 (diff)
downloadJellySolutions-07d191cb1fc8890f66e9af7d19e8276089d18d8b.tar.gz
JellySolutions-07d191cb1fc8890f66e9af7d19e8276089d18d8b.tar.bz2
JellySolutions-07d191cb1fc8890f66e9af7d19e8276089d18d8b.zip
added more sort options; fix HTML error
Diffstat (limited to '')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts15
1 files changed, 14 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 be444fb..06bb17e 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
@@ -16,13 +16,24 @@ const sortByName: sortAlgo = (a: Need, b: Need): number => {
return 1;
}
+const sortByNameReverse: sortAlgo = (a: Need, b: Need): number => {
+ return sortByName(a,b)*-1;
+}
+
const sortByMaxGoal: sortAlgo = (a: Need, b: Need): number => {
- if(a.maxGoal >= b.maxGoal) {
+ if(a.maxGoal == b.maxGoal) {
+ return sortByName(a,b);
+ }
+ else if(a.maxGoal > b.maxGoal) {
return -1;
}
return 1;
}
+const sortByMinGoal: sortAlgo = (a: Need, b: Need): number => {
+ return sortByMaxGoal(a,b)*-1;
+}
+
@Component({
selector: 'app-need-list',
standalone: false,
@@ -37,6 +48,8 @@ export class NeedListComponent {
SortingAlgoArrays: {func:sortAlgo,name:string}[] = [
{func:sortByMaxGoal,name:"sortByMaxGoal"},
{func:sortByName,name:"sortByName"},
+ {func:sortByNameReverse,name:"sortByNameReverse"},
+ {func:sortByMinGoal,name:"sortByMinGoal"},
];
constructor(