shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
sortDeep
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.object
Sort an object properties the same way as the Array.sort do it but will do it recusrively to sort the object deeply.
Params
- object*-Object
The object to sort
- sort*-Function
The sort function to use
Return
- -Object
The sorted object
Example
import { sortDeep } from '@blackbyte/sugar/object';
sortDeep({
lolo: { weight: 2 },
coco: { weight: 10 },
plop: { weight: 5 },
aha: {
hello: 'world',
coco: 'plop'
}
}, (a, b) => {
return a.key.localeCompare(b.key);
});
// {
// aha: {
// coco: 'plop',
// hello: 'world'
// }
// coco: { weight: 10 }
// lolo: { weight: 2 },
// plop: { weight: 5 },
// }Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space