React does not have a built-in function to handle this (what I know), but you can use something like lodash to achieve what you want. I would also suggest changing the structure of your data a bit. See an example below.
var arr = [
{name: "orange", count: 10},
{name: "apple", count: 5},
{name: "lemon", count: 11},
{name: "grape", count: 2}
];
var newArr = _.sortBy(arr, 'count', function(n) {
return Math.sin(n);
});
var fruits = newArr.map(function(fruit) {
return(
<Fruit name={fruit.name} count={fruit.count} />
);
});
- ,