• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Double sort list in react-native

Resolved: Double sort list in react-native

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I’d like to know how to “double sort” items in react native in order to obtain a double criteria sorted list.
The data I receive from BE is a list of match: every match is an object containing 2 players, a time and a competition.
I d’like to sort items by time (so that a today match is showed before a tomorrow match) and by competition (so that a more important competition is showed before a lower one).
If two or more matches are played on the same day and within the same competition, the earlier match is showed before.
A schema better shows what I mean: I’d like to customize the UI oc the day-row, the competition-row and the match-row.
enter image description here
The data I receive from BE are formatted in this way:
enter image description here
How could I obtain what I want? I’ve tried with sortable list but with no result.
TY in advance

Answer:

The javascript docs for sort show that you can sort using an arbitrary function. I would write a function which first compares days and then compares competitions:


If you have better answer, please add a comment about this, thank you!

javascript react-native react-native-flatlist
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: significance letter above bar graphic in wrong order

01/04/2023

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Resolved: How can I implement a function depending on picked up items?

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.