Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function sortZA(selection, documentRoot) {
// @ts-ignore
const sortedArboards = arraySort(artboards(documentRoot.children), "name")
sort(selection, sortedArboards)
}
export function sortAZ(selection, documentRoot) {
// @ts-ignore
const sortedArboards = arraySort(artboards(documentRoot.children), "name", {
reverse: true
})
sort(selection, sortedArboards)
}
const sortMenus = (first: Menus, second: Menus | undefined = []): Menus => {
const sorted: Menus = sort(first, compareWithMenu(second), sortByName)
return sorted.map(item => {
if (!item.menu) return item
const found = second.find(menu => menu.name === item.name)
const foundMenu = found && found.menu
return {
...item,
menu: foundMenu
? sortMenus(item.menu, foundMenu)
: sort(item.menu, sortByName),
}
})
}
const sorter = (
data: Node[],
comparator: (a: Node, b: Node) => number,
sortDirection: SortDirection
): Node[] => {
return sort(data, [comparator, compareByHostname], {
reverse: sortDirection !== "ASC"
});
};
export default class NodesTable extends React.Component<
) {
const copiedData = data.slice();
if (sortColumn === currentSortColumn) {
return {
data:
sortDirection === currentSortDirection
? copiedData
: copiedData.reverse(),
sortColumn,
sortDirection
};
}
return {
data: sort(copiedData, sortForColumn(sortColumn), {
reverse: sortDirection !== "ASC"
}),
sortColumn,
sortDirection
};
}
public sortData = (
groups: ServiceGroup[],
sortColumn: string = this.state.sortColumn,
sortDirection: SortDirection = this.state.sortDirection
): ServiceGroup[] =>
sort(groups.slice(), sortForColumn(sortColumn), {
reverse: sortDirection !== "ASC"
});
export function ipSorter(data: Node[], sortDirection: SortDirection): Node[] {
const reverse = sortDirection !== "ASC";
return sort(data, comparators, { reverse });
}
{state.get(({ entries, config }) => {
if (!entries || !config || !children) return null
if (!isFn(children)) {
throw new Error(
'You need to pass a children as a function to your component'
)
}
const arr = Object.values(entries)
/** TODO: remove all order and logic from here in a breaking change */
const menusArr = flatArrFromObject(arr, 'menu')
const menus = sort(menusArr, (a: string, b: string) => compare(a, b))
const descending = config.ordering === 'descending'
const docs: Entry[] = sort(
arr,
(a: Entry, b: Entry) => compare(a.order, b.order, descending),
(a: Entry, b: Entry) => compare(a.name, b.name)
)
return children({
menus,
docs,
config,
})
})}
{state.get(({ entries, config }) => {
if (!entries || !config || !children) return null
if (!isFn(children)) {
throw new Error(
'You need to pass a children as a function to your component'
)
}
const arr = Object.values(entries)
/** TODO: remove all order and logic from here in a breaking change */
const menusArr = flatArrFromObject(arr, 'menu')
const menus = sort(menusArr, (a: string, b: string) => compare(a, b))
const descending = config.ordering === 'descending'
const docs: Entry[] = sort(
arr,
(a: Entry, b: Entry) => compare(a.order, b.order, descending),
(a: Entry, b: Entry) => compare(a.name, b.name)
)
return children({
menus,
docs,
config,
})
})}
sortData(data, sortDirection, prop) {
const compareFunction = getCompareFunctionByProp(prop);
const comparators = [compareFunction];
const reverse = sortDirection !== "ASC";
return sort(data, comparators, { reverse });
},