JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdn.ractivejs.org/edge/ractive.js"></script>
<main></main>
<script id='template' type='text/ractive'>
<ul>
{{#each:numbers.slice().sort(ascending)}}
<li>{{it}}<li>
{{/each}}
</ul>
<p>ascending: {{ numbers.slice().sort(ascending) }}</p>
<p>descending: {{ numbers.slice().sort(descending) }}</p>
</script>
CSS
body {
font-family: 'Helvetica Neue', arial, sans-serif;
font-weight: 200;
color: #353535;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 200;
}
JavaScript
var helpers = Ractive.defaults.data;
// assuming a and b are numbers...
helpers.ascending = function ( a, b ) {
return a - b;
};
helpers.descending = function ( a, b ) {
return b - a;
};
ractive = new Ractive({
el: 'body',
template: '#template',
data: {
numbers: [ 9, 4, 6, 2, 4, 1, 10, 2, 7, 8 ]
}
});