add compasibility
This commit is contained in:
parent
d96b78a7e5
commit
5e518a2ad3
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user