From 2b3a5945e58f2bceaf58d05b788ea0e6a0a3cb31 Mon Sep 17 00:00:00 2001 From: Evelyn <122575337+evelyn-hur@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:42:09 -0800 Subject: [PATCH] Sort datatype dictionary into array of tuples Sort datatype dictionary into array of key-value tuples --- Prisma/PrivacyControls/PrivacyModule.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Prisma/PrivacyControls/PrivacyModule.swift b/Prisma/PrivacyControls/PrivacyModule.swift index 18d28c7..5889b05 100644 --- a/Prisma/PrivacyControls/PrivacyModule.swift +++ b/Prisma/PrivacyControls/PrivacyModule.swift @@ -75,13 +75,14 @@ public class PrivacyModule: Module, EnvironmentAccessible { public func getDataCategoryItems() -> [DataCategoryItem] { var dataCategoryItems: [DataCategoryItem] = [] - // loop through keys in dict and create a list of dataCategoryItem elements - for key in iconsMapping.keys { + // make dictionary into alphabetically sorted array of key-value tuples + let sortedDataCategoryItems = identifierUIString.sorted { $0.key < $1.key } + for dataCategoryPair in sortedDataCategoryItems { dataCategoryItems.append( DataCategoryItem( - name: key, - iconName: (iconsMapping[key] ?? "unable to get icon string"), - enabledStatus: (togglesMap[key] ?? true) ? "Enabled" : "Disabled" + name: dataCategoryPair.0, + iconName: (iconsMapping[dataCategoryPair.0] ?? "unable to get icon string"), + enabledStatus: (togglesMap[dataCategoryPair.0] ?? true) ? "Enabled" : "Disabled" ) ) }