add compasibility
This commit is contained in:
parent
d96b78a7e5
commit
5e518a2ad3
@ -37,12 +37,18 @@ interface DirListProps {
|
|||||||
}
|
}
|
||||||
const natsortCompare = natsort();
|
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) {
|
export function DirList(props: DirListProps) {
|
||||||
const data = props;
|
const data = props;
|
||||||
const [files, setFiles] = useState(
|
const [files, setFiles] = useState(
|
||||||
data.files.toSorted(
|
toSorted(data.files,(
|
||||||
(a,b)=> natsortCompare(a.name,b.name)
|
(a,b)=> natsortCompare(a.name,b.name)
|
||||||
)
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user