Sorts the properties of an object alphabetically, ascending or descending. It does not mutate the original object.
REMEMBER: In theory, JS engines do not guarantee the order of object properties. In practice most of the popular engines do.
sortProps({ b: 2, a: 1, z: 26 }) // { a: 1, b: 2, z: 26 } Copy
sortProps({ b: 2, a: 1, z: 26 }) // { a: 1, b: 2, z: 26 }
source object
sort ascending?
Sorts the properties of an object alphabetically, ascending or descending. It does not mutate the original object.
REMEMBER: In theory, JS engines do not guarantee the order of object properties. In practice most of the popular engines do.
Example