Schafkopf-Server/Sources/App/Extensions/Array+Extensions.swift
2021-12-06 11:43:30 +01:00

16 lines
373 B
Swift

import Foundation
extension Array {
func rotated(toStartAt index: Int) -> [Element] {
guard index != 0 else {
return self
}
return Array(self[index..<count] + self[0..<index])
}
func sorted<T>(by converting: (Element) -> T) -> [Element] where T: Comparable {
sorted { converting($0) < converting($1) }
}
}