views:

329

answers:

2

Code as reference:

http://jsbin.com/aboca3/2/edit

In this example above (thank you SLaks) I am truncating long unordered lists and providing a toggle link to view the entire thing.

The issue, from a usability standpoint, is that as a full list, it is best sorted alphabetically, which will be the default sort order (the source order). As a short/truncated list, they are most usefully ordered by the magnitude these options will effect the results, in this case the number in the <em> element.

So working with the code I already have, I would like to re-order the list numerically by <em> element (highest to lowest), and then when the list is toggled, re-order it alphabetically/numerically based on toggle state.

I'm having a hell of a time trying to wrap this in to an associative array so I'd love a fresh perspective on how to handle this.

Thank you!

+3  A: 

This should do it for you: http://jsbin.com/aboca3/5/edit

PetersenDidIt
This is almost exactly what I'm after. There seems to be a bug though, or perhaps I did not explain properly.When viewing only 5, only the first 5 items are sorted by em value, when I need all the facets sorted by em value and then truncated.
Greg-J
A: 

Using petersendidit's code I was able to acheive exactly the result I was looking for. You can view it here:

http://jsbin.com/aboca3/7/edit

Greg-J