JSFiddle - React, Tailwind, and code Playground
HTML
<div class="genres"> <a title="90 items" href="?genre=absurdism"><span>absurdism</span></a>
<a title="46 items" href="?genre=historical"><span>historical</span></a>
<a title="322 items" href="?genre=adult"><span>adult</span></a>
<a title="2974 items" href="?genre=adventure"><span>adventure</span></a>
<a title="83 items" href="?genre=action"><span>action</span></a>
<a title="106 items" href="?genre=about+comics"><span>about comics</span></a>
</div>
CSS
.genres a span {
background: none repeat scroll 0 0 #FFEECC;
border-radius: 2px 2px 2px 2px;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
color: #333333;
overflow: hidden;
padding: 0 3px;
}
.genres a {
color: #666666;
font-size: 1.2em;
padding: 1px 4px 1px 0;
white-space: nowrap;
}
JavaScript
sorted = $('.genres a').sort(function (a, b) {
return a.innerHTML > b.innerHTML
});
$('.genres').html('');
sorted.each(function (i, a) {
$('.genres').append(a)
});