d
Amit DhamuSoftware Engineer
 

Sort an object

1 minute read 00000 views
const sortObject = obj =>
  Object.keys(obj)
    .sort()
    .reduce(
      (acc, curr) => ({
        ...acc,
        [curr]: obj[curr],
      }),
      {}
    )