我有一组数据。当我选择筛选条件时,我想查询所有的数据,并将符合筛选条件的值显示在查询结果的前面。
例如
[
{color: 'blue', name: 'four'},
{color: 'green', name: 'five'},
{color: 'red', name: 'one'},
{color: 'red', name: 'two'},
{color: 'red', name: 'three'}
]
当我选择color:red
,并限制4个时,我想获取数据
[
{color: 'red', name: 'one'},
{color: 'red', name: 'two'},
{color: 'red', name: 'three'},
{color .........}// the fourth of data are not concerned for now
]
当我选择color:blue
,并限制4时,我想获取数据
[
{color: 'blue', name: 'four'},
{color ........},
{color ........},
{color .........}// now just care the first data
]
有什么函数可以实现这个功能吗?
我的英语很差,希望意思清楚。
无论如何,谢谢!
最佳答案
关于javascript - 如何根据字段的值进行排序?蒙戈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47649363/