blob: 6099b99891483646efc8db2f64662adbdcdbbe9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*!
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
export interface Orderable {
order: number;
}
export function sortOrderables<T extends Orderable>(menu?: T[]): T[] {
const result = [...(menu || [])];
result.sort((lhs, rhs) => {
if (lhs.order < rhs.order) {
return -1;
}
if (lhs.order > rhs.order) {
return 1;
}
return 0;
});
return result;
}
|