问题
缺少一些简单的排序方式,无论是升序,降序等。我无法更改顺序,但默认排序仍然存在。假设我在sort属性中做错了什么?
文档
https://docs.amplify.aws/ui/storage/s3-album/q/framework/react#props-attr-amplify-s3-album
组件代码
import Amplify, { Storage } from ‘aws-amplify’;
import {AmplifyS3Album} from “@aws-amplify/ui-react”;
import { AccessLevel,StorageObject } from ‘@aws-amplify/ui-components’
<AmplifyS3Album
path=''
pickerText='Upload ..'
picker={false} level={AccessLevel.Public}
sort={
(list: StorageObject[]) => {
console.log('default acended sorted, before sort output', list);
const sortedList: StorageObject[] = list.sort((a:any, b:any) => a['key'].localeCompare(b['key'])); //descending sort
console.log('after decended sort', sortedList); //NOTE: see output below, still ascending sorted, same output for the list
return sortedList;
}
}
/>
相同的控制台输出,无论使用升序还是降序
{key: “five.png”, eTag: “”4fe9ff4f95e20e86e88d57c084289192"“, lastModified: Sat Nov 07 2020 13:58:44 GMT+0000 (Greenwich Mean Time), size: 18941, contentType: “image/png”}
{key: “four.png”, eTag: “”0d06490b80a75428b9c9ebb04a1858ab”“, lastModified: Sat Nov 07 2020 13:54:41 GMT+0000 (Greenwich Mean Time), size: 15373, contentType: “image/png”}
{key: “one.png”, eTag: “”a9c003fdbff9eecc7608ddefed5912b6"“, lastModified: Fri Nov 06 2020 16:47:54 GMT+0000 (Greenwich Mean Time), size: 13106, contentType: “image/png”}
{key: “three.png”, eTag: “”5144c243f0b6e807548946b958648b6d”“, lastModified: Fri Nov 06 2020 16:50:39 GMT+0000 (Greenwich Mean Time), size: 19373, contentType: “image/png”}
{key: “two.png”, eTag: “”59627b1023a93c02f8142e0070c18f38"“, lastModified: Fri Nov 06 2020 16:50:31 GMT+0000 (Greenwich Mean Time), size: 19443, contentType: “image/png”}