Skip to content

Instantly share code, notes, and snippets.

@jonathontoon
Last active October 20, 2019 03:08
Show Gist options
  • Save jonathontoon/6681c06890bb1c6c9b77239e38d158b2 to your computer and use it in GitHub Desktop.
Save jonathontoon/6681c06890bb1c6c9b77239e38d158b2 to your computer and use it in GitHub Desktop.
Sorting List
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