From ee0353138bc21dfa80e3a0c1d01023abcd2f18f3 Mon Sep 17 00:00:00 2001
From: Furkan Sahin <furkan-dev@proton.me>
Date: Sun, 7 Aug 2022 18:56:33 -0500
Subject: Introduce layer of indirection to PT sorting function

---
 src/components/PeerTeachers.svelte | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/components/PeerTeachers.svelte')

diff --git a/src/components/PeerTeachers.svelte b/src/components/PeerTeachers.svelte
index 36efef1..6aa7b5f 100644
--- a/src/components/PeerTeachers.svelte
+++ b/src/components/PeerTeachers.svelte
@@ -11,11 +11,13 @@
 
   let snackbarSuccess: SnackbarComponentDev;
 
-  $: peerTeachers = [...$ptStore.values()].sort((a, b) =>
-    a.lastname.toUpperCase() === b.lastname.toUpperCase()
+  // TODO introducing layer of indirection to how Peer Teachers are displayed in order to sort based on aribitrary paramters
+  function ptSort(a: PeerTeacher, b: PeerTeacher): number {
+    return a.lastname.toUpperCase() === b.lastname.toUpperCase()
       ? a.firstname.toUpperCase().localeCompare(b.firstname.toUpperCase())
-      : a.lastname.toUpperCase().localeCompare(b.lastname.toUpperCase())
-  );
+      : a.lastname.toUpperCase().localeCompare(b.lastname.toUpperCase());
+  }
+  $: peer_teachers = [...$ptStore.values()].sort(ptSort);
 
   function deletePT(id: number) {
     // Unassign all labs assigned to this Peer Teacher
-- 
cgit v1.2.3

