MCPcopy Create free account
hub / github.com/Effect-TS/effect / sortBy

Function sortBy

packages/effect/src/Array.ts:2259–2272  ·  view source on GitHub ↗
(
  ...orders: ReadonlyArray<Order.Order<ReadonlyArray.Infer<S>>>
)

Source from the content-addressed store, hash-verified

2257 * @since 2.0.0
2258 */
2259export const sortBy = <S extends Iterable<any>>(
2260 ...orders: ReadonlyArray<Order.Order<ReadonlyArray.Infer<S>>>
2261) => {
2262 const sortByAll = sort(Order.combineAll(orders))
2263 return (
2264 self: S
2265 ): S extends NonEmptyReadonlyArray<infer A> ? NonEmptyArray<A> : S extends Iterable<infer A> ? Array<A> : never => {
2266 const input = fromIterable(self)
2267 if (isReadonlyArrayNonEmpty(input)) {
2268 return sortByAll(input) as any
2269 }
2270 return [] as any
2271 }
2272}
2273
2274/**
2275 * Pairs elements from two iterables by position. If the iterables differ in

Callers

nothing calls this directly

Calls 1

fromIterableFunction · 0.70

Tested by

no test coverage detected