Files
explore/ui/shared/monaco/utils/sortFileTree.ts
T
2023-04-17 15:54:39 -03:00

15 lines
359 B
TypeScript

import type { FileTree } from '../types';
import type { ArrayElement } from 'types/utils';
export default function sortFileTree(a: ArrayElement<FileTree>, b: ArrayElement<FileTree>) {
if ('children' in a && !('children' in b)) {
return -1;
}
if ('children' in b && !('children' in a)) {
return 1;
}
return a.name.localeCompare(b.name);
}