Method multiorder documentation
Sorts an array of objects based on a set of properties.
Example
```javascript
let ar = [
{movie: "Brazil", year: 1985},
{movie: "Donnie Darko", year: 2001},
{movie: "Out of Africa", year: 1985},
{movie: "Ran", year: 1985},
{movie: "Back to the future", year: 1985},
{movie: "Barry Lindon", year: 1976}
];
bbn.fn.multiorder(ar, [
{field: "year", dir: "desc"},
{field: "movie", dir: "asc"}
]);
// [
// {movie: "Donnie Darko", year: 2001},
// {movie: "Back to the future", year: 1985},
// {movie: "Brazil", year: 1985},
// {movie: "Out of Africa", year: 1985},
// {movie: "Ran", year: 1985},
// {movie: "Barry Lindon", year: 1976}
// ]
bbn.fn.multiorder(ar, {year: "desc", movie: "asc"});
// Same result with object shortcut
```
Sorts an array of objects based on a set of properties. - The resulting array is the same object, the order is based on _compareValues function
applied for each given properties in orders argument.
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions