Last active
October 20, 2019 03:08
-
-
Save jonathontoon/6681c06890bb1c6c9b77239e38d158b2 to your computer and use it in GitHub Desktop.
Sorting List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import List from "./List"; | |
import ListItem from "./ListItem"; | |
const ListComponent = ({ unsortedItems }) => { | |
const sortedItemsByAscending = unsortedItems.sort((a, b) => { | |
return a.value > b.value; | |
}); | |
return ( | |
<List> | |
{sortedItemsByAscending && sortedItemsByAscending.map((item) => { | |
return ( | |
<ListItem value={item.value} /> | |
); | |
})} | |
</List> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment