A widget written in React to sort countries by the number of medals won.
The widget is initialized with an id and a default sort:
<script src="medal-widget.js" type="text/babel"></script>
<script type="text/babel">
widget.initialize('#medal-widget', 'gold');
</script>
The widget will sort the countries by most medals won using the given sort. If there is a tie, the countries are sorted by the next-nearest medal using the following hash:
// Hash of secondary sort parameters to break ties
// e.g. If sorted by gold, break ties by most silver
const secondarySort = {
total: 'gold',
gold: 'silver',
sliver: 'gold',
bronze: 'gold'
};
The user can also click on the table headers to change sort
example:
# Install dependencies
$ npm install
# Run browser sync server
$ npm start