Thank you, this is brilliant and just what I needed for a hieroglyphs app (Glyph Quiz). I use slightly different IPA phonetics
extension StringProtocol {
// credit: https://stackoverflow.com/questions/75253242/customized-sort-order-in-swift
var glyphEncoding: [Int] { map { Dictionary(uniqueKeysWithValues: "ꜣyꞽꜥwbpfmnrhḥḫẖszšḳkgtṯdḏ"
.enumerated()
.map { (key: $0.element, value: $0.offset) } )[$0] ?? -1 } }
// Usage: phoneticStrings.sorted { $0.glyphEncoding.lexicographicallyPrecedes($1.glyphEncoding) }
}
(needs an IPA font like CharisSIL installed)