Hello I want to sort an object within renderItem
of FlatList
.I'm getting array of objects as server response.I want to do sorting within these objects.I've a list of cars with their price. If the user click on sort button of car with lowest price first.I want to show the cars with lowest price first in the list.The structure of item
within renderItem
is as follows.
The expanded structure of single item
is as follows.I want to sort the object by its priceTotal
.
Following is my code which I've done so far.Please help to find a solution.
sample code
renderItems = ({ item, index }) => {
return (
<CarReservationDetailComponent
carName={item.make}
carType={item.carType}
carPrice1={item.priceTotal}
mileage
mileageText={item.autonomy + 'km. restantes'}
imageUri={item.picture}
/>
)
}
.....
<FlatList
data={this.props.value.value}
renderItem={this.renderItems}
ItemSeparatorComponent={this.renderSeparator}
showsVerticalScrollIndicator={false}
/>