Skip to content

Commit

Permalink
Sort datatype dictionary into array of tuples
Browse files Browse the repository at this point in the history
Sort datatype dictionary into array of key-value tuples
  • Loading branch information
evelyn-hur committed Mar 5, 2024
1 parent 48e3ca9 commit 2b3a594
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Prisma/PrivacyControls/PrivacyModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)
}
Expand Down

0 comments on commit 2b3a594

Please sign in to comment.