UNPKG

@orbitdb/ordered-keyvalue-db

Version:

Ordered keyvalue database type for orbit-db.

8 lines (7 loc) 256 B
export const sortPosition = <T>(array: (T & { position: number })[]): T[] => { const sorted = array.toSorted((a, b) => a.position - b.position); return sorted.map((x) => { delete (x as T & { position?: number })["position"]; return x; }); };