网站更新内容:请访问: https://bigdata.ministep.cn/

react中的api获取数组排序

[javascript - Sort an array of objects in React and render them - Stack Overflow](https://stackoverflow.com/questions/43572436/sort-an-array-of-objects-in-react-and-render-them)

```

// ... rest of code

// copy your state.data to a new array and sort it by itemM in ascending order
// and then map 
const myData = [].concat(this.state.data)
    .sort((a, b) => a.itemM > b.itemM ? 1 : -1)
    .map((item, i) => 
        <div key={i}> {item.matchID} {item.timeM}{item.description}</div>
    );

// render your data here...

```

示例: 

 

posted @ 2022-12-22 12:26  ministep88  阅读(31)  评论(0编辑  收藏  举报
网站更新内容:请访问:https://bigdata.ministep.cn/