UNPKG

rambda

Version:

Lightweight and faster alternative to Ramda with included TS definitions

16 lines (12 loc) 343 B
import { sort } from './sort.js' export function sortObject(predicate) { return obj => { const keys = Object.keys(obj) const sortedKeys = sort((a, b) => predicate(a, b, obj[a], obj[b]))(keys) const toReturn = {} sortedKeys.forEach(singleKey => { toReturn[singleKey] = obj[singleKey] }) return toReturn } }