add compasibility

This commit is contained in:
monoid 2023-02-14 21:42:56 +09:00
parent d96b78a7e5
commit 5e518a2ad3
1 changed files with 8 additions and 2 deletions

View File

@ -37,12 +37,18 @@ interface DirListProps {
}
const natsortCompare = natsort();
function toSorted<T>(arr: T[], compareFn: (a:T,b:T) => number): T[]{
const ret = Array.from(arr);
ret.sort(compareFn);
return ret;
}
export function DirList(props: DirListProps) {
const data = props;
const [files, setFiles] = useState(
data.files.toSorted(
toSorted(data.files,(
(a,b)=> natsortCompare(a.name,b.name)
)
))
);
return (