Files
explore/ui/shared/monaco/utils/sortFileTree.ts
T
2023-03-22 11:11:30 -03:00

15 lines
368 B
TypeScript

import type { FileTree } from '../types';
import type ArrayElement from 'types/utils/ArrayElement';
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);
}