Schafkopf-Server/Sources/App/Extensions/Array+Extensions.swift

16 lines
373 B
Swift
Raw Normal View History

2021-12-01 22:48:10 +01:00
import Foundation
extension Array {
func rotated(toStartAt index: Int) -> [Element] {
guard index != 0 else {
return self
}
return Array(self[index..<count] + self[0..<index])
}
2021-12-06 11:43:30 +01:00
func sorted<T>(by converting: (Element) -> T) -> [Element] where T: Comparable {
sorted { converting($0) < converting($1) }
}
2021-12-01 22:48:10 +01:00
}