HealthImport/HealthImport/Support/Sequence+Extensions.swift
2024-01-25 13:48:00 +01:00

14 lines
336 B
Swift

import Foundation
extension Sequence {
func sorted<T>(ascending: Bool = true, using conversion: (Element) -> T) -> [Element] where T: Comparable {
if ascending {
return sorted { conversion($0) < conversion($1) }
} else {
return sorted { conversion($0) > conversion($1) }
}
}
}